Created
February 24, 2014 01:21
-
-
Save mshuffett/9180158 to your computer and use it in GitHub Desktop.
Python metaclass demonstration
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 MetaCommand(type): | |
def __new__(meta, name, bases, dct): | |
print '-----------------------------------' | |
print "Allocating memory for class", name | |
print meta | |
print bases | |
print dct | |
return super(MetaCommand, meta).__new__(meta, name, bases, dct) | |
def __init__(cls, name, bases, dct): | |
print '-----------------------------------' | |
print "Initializing class", name | |
print cls | |
print bases | |
print dct | |
super(MetaCommand, cls).__init__(name, bases, dct) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment