Skip to content

Instantly share code, notes, and snippets.

@brownan
Created May 4, 2012 14:38
Show Gist options
  • Save brownan/2595164 to your computer and use it in GitHub Desktop.
Save brownan/2595164 to your computer and use it in GitHub Desktop.
the problem with super() and reload()
class SuperClass(object):
def myfunc(self):
print "SuperClass myfunc() called"
class A(SuperClass):
def myfunc(self):
super(A, self).myfunc()
print "A.myfunc() called"
"""
>>> import module
>>> a = module.A()
>>> a.myfunc()
SuperClass myfunc() called
A.myfunc() called
>>> reload(module)
<module 'module' from 'module.pyc'>
>>> a.myfunc()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "module.py", line 8, in myfunc
super(A, self).myfunc()
TypeError: super(type, obj): obj must be an instance or subtype of type
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment