Python dynamic attribute creation

WANG Cong xiyou.wangcong at gmail.com
Thu Jul 1 11:02:57 EDT 2010


On 06/27/10 09:06, Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:

>> In that situation, certainly: adding an attribute on the fly to that
>> formal definition seems entirely strange and special of an activity. But
>> that's only because you *chose* to *see* and *use* the object that way.
>> The "special"ness of the activity is entirely in your head, and to
>> Python, its an entirely normal event.
>
> Exactly. Things which other languages make scary and mysterious 
> "metaprogramming" are, in Python, normal and ordinary programming. It 
> doesn't seem to do us any harm.
>

As long as setattr() exists in Python, that will be not so ordinary. :)

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



More information about the Python-list mailing list