Skip to content

Instantly share code, notes, and snippets.

@arsatiki
Created January 31, 2009 12:42
Show Gist options
  • Save arsatiki/55527 to your computer and use it in GitHub Desktop.
Save arsatiki/55527 to your computer and use it in GitHub Desktop.
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