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.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to