Python dynamic attribute creation

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Fri Jul 2 06:05:31 EDT 2010


WANG Cong a écrit :
> On 06/30/10 01:25, Ethan Furman <ethan at stoneleaf.us> wrote:
> 
>>> But if so why setattr() still exists? What is it for if we can do the
>>> same thing via assignments? Also, in order to be perfect, Python should
>>> accept to add dynamic attributes dynamically, something like PEP
>>> 363. That doesn't happen.
>> Setattr and friends exist to work with dynamic attributes.
>>
> 
> Yeah, my point is why setattr() for dynamic attributes while assignments
> for static attributes? Why not unify them?

What is a "dynamic" and what is a "static" attribute ????

> Agreed, but at least, the reason why I am being against so many people
> here is also trying to make Python be more perfect with my
> understanding.

Please start with learning Python's execution model (what exactly 
happens at runtime, what most statement are syntactic sugar for etc) and 
Python's object model (how are Python objects, classes, methods etc 
implemented, attributes lookup rules, metaclasses, descriptors etc).

Then PERHAPS you MIGHT have a chance to help making Python "more perfect".



More information about the Python-list mailing list