[Python-Dev] Adding __format__ to classic classes

Nick Coghlan ncoghlan at gmail.com
Wed Feb 13 23:09:36 CET 2008


Eric Smith wrote:
> I hate to be dense, but could you point me to some code that does 
> something similar but looks up the method by name?

I was going to suggest __enter__/__exit__, but that code relies mainly 
on existing opcodes and just does an attribute lookup rather than 
explicitly bypassing the instance dictionary.

However, the source code for cPickle may provide some ideas (when it 
looks up _reduce__/__getstate__/etc).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list