Bugs item #1661603, was opened at 2007-02-16 15:32
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1661603&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: Python 2.4
>Status: Closed
>Resolution: Invalid
Priority: 5
Private: No
Submitted By: Matthijs (matthijsd)
Assigned to: Nobody/Anonymous (nobody)
Summary: Misleading behavior for [] and {} default arguments

Initial Comment:
Hello

On python 2.3.4 and 2.4.3, 

>>> def a(x=[]):
...   return x
... 
>>> y=a()
>>> y.append(1)
>>> a()
[1]

Hence, the default argument is not recomputed. The same behavior occurs with 
x={} instead of x=[].

This looks like a bug because it is not coherent with 

>>> def f():
...   return []
... 
>>> y=f()
>>> y.append(5)
>>> f()
[]

So, is it a feature?

Thanks



----------------------------------------------------------------------

>Comment By: Georg Brandl (gbrandl)
Date: 2007-02-16 15:40

Message:
Logged In: YES 
user_id=849994
Originator: NO

Yes, it is. (Please post questions about Python semantics to the
comp.lang.python newsgroup, they'll explain them in detail...)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1661603&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to