question on __dict__

Terry Reedy tjreedy at
Thu Nov 22 16:30:46 CET 2001

"Markus Jais" <mjais at> wrote in message
news:pan.2001. at
> can somebody tell me, what the difference is between
> self.__dict__('foo') = 'bar'
> and
> = 'bar'

The second translates to the first *UNLESS* there is a .__setattr__()
This is what you should usually use.

Within a __setattr__() method, you *SHOULD* use the first form --
unless you want your program to get caugth in an infinite loop.

(Not sure of impact of 2.2 changes on above statements.)

Terry J. Reedy

More information about the Python-list mailing list