[Python-bugs-list] [ python-Bugs-416951 ] Problem with dictionary default argument
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 17 Apr 2001 22:29:22 -0700
Bugs item #416951, was updated on 2001-04-17 22:29
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=416951&group_id=5470
Category: Parser/Compiler
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Problem with dictionary default argument
Initial Comment:
-- Python 2.0 Win32 --
It seems to be that _default argument values_ can be
changed permanently if they are dictionaries.
Code sample:
def f(a = 1):
print a
a = 2
>>>f()
1
>>>f()
1
--> ok
def g(mydic = {}):
print mydic
mydic["test"] = 1
>>>g()
{}
>>>g()
{'test': 1}
--> bad (default argument value for 'mydic' changed)
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=416951&group_id=5470