Python dynamic attribute creation

Rami Chowdhury rami.chowdhury at gmail.com
Thu Jul 1 14:11:54 EDT 2010


On 2010-07-01 23:42, WANG Cong wrote:
> 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. :)

Is this not the practicality / purity discussion from another subthread?
You think it's "less perfect" (by which I think you actually mean "less pure"
 - but please correct me if I'm wrong). But you admit that it's more under-
standable (i.e. it's more practical). Practicality beats purity, so the 
"less pure" solution wins.

> 
> "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.
>  
> -- 
> http://mail.python.org/mailman/listinfo/python-list
----
Rami Chowdhury
"It always takes longer than you expect, even when you take Hofstadter's
Law into account." -- Hofstadter's Law
+1-408-597-7068 / +44-7875-841-046 / +88-01819-245544



More information about the Python-list mailing list