Vaguely, built-in functions (and some other types of calls) do not become related methods, since ordinary functions are executed when used in a class:
>>> class Foo(object): __getitem__ = getattr
>>> Foo().__getitem__
<built-in function getattr>
Compared with:
>>> def ga(*args): return getattr(*args)
>>> class Foo(object): __getitem__ = ga
>>> Foo().__getitem__
<bound method Foo.ga of <__main__.Foo object at 0xb77ad94c>>
So getattr gets the first ("self") parameter incorrectly. You will need to write a regular method to port it.
user79758
source
share