__set_attr__
Alex Martelli
aleaxit at yahoo.com
Thu Jan 25 05:51:42 EST 2001
"Amritansh Raghav" <amritansh at mobilian.com> wrote in message
news:t6v3s5fv3t7f3e at corp.supernews.com...
> (Newbie alert - its been less than a week)
You're using rather-advanced features, apparently; take care!
> Under what circumstances does __set_attr__ get callled?
It's spelled __setattr__. It's called, if it exists, each and
every time you set an attribute (either object.attribute=value
syntax, or setattr calls, but not with obj.__dict__['attr']=val,
which is what you may need inside your __setattr__ to avoid
accidentally recursing).
> I thought it was only if the name wasnt found in the dictionary.
This is the semantics of __getattr__.
> This is happening within my constructor so I wonder if I need to do
> something special here
No, the rules don't change, whether __init__ is being executed
at the time, or not.
Alex
More information about the Python-list
mailing list