use of hasattr(), getattr(), __dict__, was re: Python evangelists unite!
wurmy at earthlink.net
Sat Dec 1 21:14:43 CET 2001
adina_levin at mindspring.com wrote:
> What do people think is good-form use of hasattr(), getattr(), and __dict__,
> as opposed to bad magic or suboptimal style?
I think there's nothing wrong with using hasattr, getattr or
setattr... __dict__ is a bit more tricky, but it still seems to
be an acceptable solution in some cases, like, for example,
preventing recursive calls in a __setattr__ method. Then again,
if, in a given situation, you can think of a solution that does
not require tinkering with attributes, it's probably better...
There. Was that vague or what? ;-)
More information about the Python-list