All pastes #895416 Raw Edit

attributeError

public text v1 · immutable
·published 2008-02-07 20:19 UTC
rendered paste body
>>> class A(object):
...     def __init__(self):
...             self.name = "A"
...             self.myFunction()
...
>>> class B(A):
...     def __init__(self):
...             super(B, self).__init__()
...             self.count = 0
...     def myFunction(self):
...             print self.count
...
>>> o = B()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 3, in __init__
  File "<stdin>", line 4, in __init__
  File "<stdin>", line 6, in myFunction
AttributeError: 'B' object has no attribute 'count'
>>>