Re:Metaclasses in Python
by reinhardt on Thursday December 15, 2011 @01:13PM
(#3357221)
The above doesn't really work as the builtin object class doesn't allow extra attributes. Still any pure Python class does by default:
[ Parent
| on HN ]
You should either remove `self` or bind it differently:
foo = Foo()
def hello():
print("hello, %s" % (foo,))
foo.hello = hello
`foo` is an instance therefore `self == foo` already. def hello(self):
print("hello, %s" % (self,))
foo.hello = types.MethodType(hello, foo)