__dict__ is neato torpedo!

Andrew Berg bahamutzero8825 at gmail.com
Sat Jun 11 22:28:40 EDT 2011


On 2011.06.11 09:13 PM, Steven D'Aprano wrote:
> So never update from a random object you don't know well.
Of course. In the project I'm working on, this will be used in the
__init__() method of a class that accepts a pair of dictionaries or
possibly **kwargs (for flexibility and to avoid the very problem of an
object without a __dict__).
> A second, more subtle risk: not all objects have a __dict__. But if you 
> obey the rule about never updating from arbitrary objects you don't know, 
> then you won't be surprised by an object with no __dict__.
What objects don't (other than the obvious ones like strings,
dictionaries, ints and lists)?



More information about the Python-list mailing list