Created
January 31, 2009 12:42
-
-
Save arsatiki/55527 to your computer and use it in GitHub Desktop.
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 Additive(type): | |
def __add__(self, x): | |
return type("Additive", (self, x), {}) | |
class A(object): | |
__metaclass__ = Additive | |
def foo(self): | |
print "foo" | |
class B(object): | |
def bar(self): | |
print "bar" | |
ab = (A+B)() | |
ab.bar() => "bar" | |
ab.foo() => "foo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment