Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 16th, 2012  |  syntax: None  |  size: 0.59 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Python: 'super' object has no attribute 'attribute_name'
  2. class Parent(object):
  3.     def __init__(self, value):
  4.         self.some_var = value
  5.        
  6. class Child(Parent):
  7.     def __init__(self, value):
  8.         super(Child, self).__init__(value)
  9.  
  10.     def doSomething(self):
  11.         parent_var = super(Child, self).some_var
  12.        
  13. obj = Child(123)
  14. obj.doSomething()
  15.        
  16. Traceback (most recent call last):
  17.   File "test.py", line 13, in <module>
  18.     obj.doSomething()
  19.   File "test.py", line 10, in doSomething
  20.     parent_var = super(Child, self).some_var
  21. AttributeError: 'super' object has no attribute 'some_var'