Bug in python!? persistent value of an optional parameter in function!
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Wed Mar 7 21:56:37 EST 2007
En Wed, 07 Mar 2007 23:39:21 -0300, C Barr Leigh <cpblPublic at gmail.com>
escribió:
> Help! Have I found a serious bug?
Not at all! This is by design.
> def testPersistence(anarg,twooption=[]):
> #print anarg
> if not twooption:
> twooption.append('Set within test for '+anarg)
See
http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm
--
Gabriel Genellina
More information about the Python-list
mailing list