Guido van Rossum wrote: >> Much to my surprise, this already works: >> >> >>> format(oldstyle(), '+^50s') >> '+++++<__main__.oldstyle instance at 0x3d91f8>+++++' >> >>> >> >> So I guess it's a moot point. I'm using the same code as I use in 3.0, >> where I call: >> meth = _PyType_Lookup(Py_TYPE(value), format_str); >> where format_str is "__format__" interned. And I'm getting a value back >> for old style classes. >> >> Eric. > > But now try overriding __format__(). The 3.0 code uses > _PyType_Lookup() which is not traversing the class dicts for classic > classes, so it won't find __format__ overrides. > Okay, I see and understand that issue. But looking at len or getattr, I don't see how to generalize it to __format__. __len__ and __getattr__ have special support in the classes, with cl_getattr, tp_getattr, etc. I hate to be dense, but could you point me to some code that does something similar but looks up the method by name? Thanks for your time. Eric.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4