Python dynamic attribute creation

WANG Cong xiyou.wangcong at gmail.com
Thu Jul 1 11:42:20 EDT 2010


On 07/01/10 22:53, Stephen Hansen <me+list/python at ixokai.io> wrote:

>
> One uses assignment syntax when the name of the attribute they are
> setting is known at the time when one writes the code.
>
> One uses the setattr function when the name of the attribute is not
> known until runtime.
>
> The difference has *nothing at all* to do with "programming classes"
> or "dynamic" vs "static".
>

This is exactly what I am thinking.

What we differ is that if using both assignment syntax and setattr()
builtin function is a good design. You think the current design which
lets them co-exist is more understandable, while I think this is less
perfect and then not that more understandable. :)

"Understandable" is hard to define, it differs so much from person to
person. "Perfect" is a strong sense for which I enjoy programming and
learn programming languages.

Thanks much for your detailed answers, I like discussing this with you!


-- 
Live like a child, think like the god.
 



More information about the Python-list mailing list