Created
May 4, 2012 14:38
-
-
Save brownan/2595164 to your computer and use it in GitHub Desktop.
the problem with super() and reload()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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