Reputation: 7236
I have a classes ConfTest
and SubConfigTest
which looks like this:
class ConfTest():
config = {
'account': Account
}
def __init__(self,
account):
self.account = account
...
class SubConfigTest(ConfTest):
def __init__(self):
super(SubConfigTest, self).__init__(account=self.account)
self.path = install_test(self.ver_config)
I want SubConfigTest
to have all the properties of ConfTest
.
When I run my program I get this error:
super(SubConfigTest, self).__init__(account=self.account,
AttributeError: 'SubConfigTest' object has no attribute 'account'
Where am I going wrong? I feel like I must declare account
somewhere in SubConfigTest
but I'm not sute how or where. I only added it because if I leave it out I get an error saying:
super(SubConfigTest, self).__init__()
TypeError: init() takes exactly 2 arguments (1 given)
Upvotes: 0
Views: 36
Reputation: 8540
In line super(SubConfigTest, self).__init__(account=self.account)
the part account=self.account
is evaluated before calling __init__
of base class, where is the definition self.account = account
, that's why the error occures. You probably forget to pass account
as a parameter to SubConfigTest.__init__
:
class SubConfigTest(ConfTest):
def __init__(self, account):
super(SubConfigTest, self).__init__(account=account)
self.path = install_test(self.ver_config)
Upvotes: 1