[Tutor] Problem with calling class methods stored in a list

Tobias M. tm at tobix.eu
Thu Jan 10 14:03:58 CET 2013


Am 10.01.2013 13:57, schrieb eryksun:
> That should be
>
>      cls.method_list[0].__get__(None, cls)()
>
> The way you have it binds the method to type(MyClass), which in this
> case is "type" itself. See cm_descr_get in funcobject.c, CPython 2.7
> (line 645):
>
> http://hg.python.org/cpython/file/70274d53c1dd/Objects/funcobject.c#l635
>
> Also see the slot wrapper wrap_descr_get for the mapping from None to
> NULL (line 4671):
>
> http://hg.python.org/cpython/file/70274d53c1dd/Objects/typeobject.c#l4660
This works. Thanks!


More information about the Tutor mailing list