Created
May 4, 2012 22:43
-
-
Save startling/2598169 to your computer and use it in GitHub Desktop.
metaclasses explained
This file contains 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 FalseClass(type): | |
def __int__(self): | |
return 13 | |
class C(object): | |
__metaclass__ = FalseClass | |
print int(C) | |
c = C() | |
# this raises an error, since c.__int__ doesn't exist; | |
# it's an instance of a class, not a class itself. | |
print int(c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment