Eric Snow added the comment:

Couldn't you make use of inspect.getattr_static()?

  getattr_static(obj.__class__, '__index__').__get__(obj)()

getattr_static() does some extra work to get do the right lookup.  I haven't 
verified that it matches _PyType_Lookup() exactly, but it should be pretty 
close at least.

Also, pickle (unfortunately) also does lookup on instances rather than classes 
for the special methods (issue #16251).

----------
nosy: +eric.snow

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18712>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to