__dict__ is neato torpedo!
Tim Chase
python.list at tim.thechases.com
Sun Jun 12 06:57:40 EDT 2011
On 06/11/2011 08:32 PM, Andrew Berg wrote:
> I'm pretty happy that I can copy variables and their value from one
> object's namespace to another object's namespace with the same variable
> names automatically:
>
> b.__dict__.update(a.__dict__)
>
> The reason I'm posting this is to ask what to watch out for when doing
> this. I've seen vague warnings that I don't really understand, and I'm
> hoping someone can enlighten me.
I guess the summary is is "it does *exactly* what an Python
experienced programmer would expect it to, so if things break you
get to keep both pieces" (which even nicely summarizes Steven's
sub-thread about objects lacking __dict__). Based on your
reactions to the replies, I'd say you're sufficiently experienced
in Python to have your expectations align with Python reality.
-tkc
More information about the Python-list
mailing list