An interesting python problem

bruno modulix onurb at xiludom.gro
Wed Sep 14 11:28:18 CEST 2005


Johnny Lee wrote:
> bruno modulix wrote:
> 
>>I dont see anything interesting nor problematic here. If you understand
>>the difference between class attributes and instance attributes, the
>>difference between mutating an object and rebinding a name, and the
>>attribute lookup rules in Python, you'll find that all this is the
>>normal and expected behavior.
>>
>>Or did I miss something ?
>>
> 
> 
> No, you didn't miss anything as I can see. Thanks for your help:)

You're welcome !-)

Ok, I guess all this is not that intuitive, specially when comes from
less dynamic languages. Python's object model is quite powerful, but one
need to have a good understanding of it to understand *why* it works
that way. There's an interesting slideshow about metaclasses and
descriptors that may help (if your brain is robust enough !-) :

http://www.python.org/pycon/dc2004/papers/24/metaclasses-pycon.pdf

HTH
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list