Reputation: 887
I am trying this
In [1]: class Parent:
...: def __init__(self):
...: self.a =10
...: self.b =20
...:
In [3]: class NewParent(Parent):
def __init__self():
super(NewParent,self).__init__()
self.c =30
...:
When i do this
In [4]: c = NewParent()
In [5]: c
Out[5]: <__main__.NewParent instance at 0x2c98878>
In [6]: c.a
Out[6]: 10
In [7]: c.b
Out[7]: 20
In [8]: c.c
AttributeError Traceback (most recent call last) in () ----> 1 c.c
AttributeError: NewParent instance has no attribute 'c'
Upvotes: 0
Views: 57
Reputation: 5588
class NewParent(Parent):
def __init__self():
super(NewParent,self).__init__()
self.c =30
should be
class NewParent(Parent):
def __init__(self):
#Your code here
Upvotes: 0
Reputation: 798686
You goofed the method declaration on NewParent
.
def __init__(self):
Upvotes: 1