There was an error while loading. Please reload this page.
List of many of the quirks that are needed for Pythons black magic:
name mangling: http://docs.python.org/reference/expressions.html#atom-identifiers
>>> class Class(object): ... pass ... >>> def foo(self): ... return self ... >>> o = Class() >>> Class.foo = foo >>> print type(foo), type(Class.foo), type(o.foo) <type 'function'> <type 'instancemethod'> <type 'instancemethod'> >>> print foo, Class.foo, o.foo <function foo at 0x02331330> <unbound method Class.foo> <bound method Class.foo of <__main__.Class object at 0x01DDF670>> >>> foo("Hello World") 'Hello World' >>> Class.foo() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unbound method foo() must be called with Class instance as first argument (got nothing instead) >>> o.foo() <__main__.Class object at 0x01DDF670>