Skip to content

Instantly share code, notes, and snippets.

@mshuffett
Created February 24, 2014 01:21
Show Gist options
  • Save mshuffett/9180158 to your computer and use it in GitHub Desktop.
Save mshuffett/9180158 to your computer and use it in GitHub Desktop.
Python metaclass demonstration
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