Created
April 8, 2013 19:49
-
-
Save pcote/5339900 to your computer and use it in GitHub Desktop.
Playing around with custom class construction just to see how it works. Good dumb fun.
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
# meta_troll.py | |
# This is me messing around with Python type constructors just for fun. | |
# Try and see what happens if you uncomment the __metaclass__ line in Foo. | |
class TrollType(type): | |
def __new__(meta, classname, bases, clssDict): | |
class MyTroll(object): | |
def say_stuff(self): | |
print("you mad bro?") | |
return MyTroll | |
class Foo(object): | |
#__metaclass__ = TrollType | |
def say_stuff(self): | |
print("hi there buddy!") | |
if __name__ == '__main__': | |
f = Foo() | |
f.say_stuff() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment