default value in __init__

Christian Heimes lists at cheimes.de
Thu Oct 9 04:14:49 EDT 2008


kenneth wrote:
> the 'd' variable already contains the 'self.d' value of the first
> instance and not the default argument {}.
> 
> Am I doing some stupid error, or this is a problem ?

No, it always contains the default argument because default values are 
created just ONE TIME. 
http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm




More information about the Python-list mailing list