Bart van Deenen wrote:
Hi all.
I've stumbled onto a python behavior that I don't understand at all.
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
# function
def X(l=[]):
l.append(1)
print l
# first call of X
X()
[1]
#second call of X
X()
[1, 1]
Where does the list parameter 'l'
Bart van Deenen wrote:
I've stumbled onto a python behavior that I don't understand at all.
http://effbot.org/zone/default-values.htm
Is this correct behavior or is it a Python bug?
Python's been out there for nearly 20 years. I think you safely can
assume that if this really was a bug,
Diez B. Roggisch wrote:
> It's amazing. I didn't analyse this properly, but IMHO this issue is the
> single most asked question (or rather the effects in produces) on this
> list.
I feel a bit dumb to ask a FAQ on the newsgroup. The problem with this
particular question is that I found it hard to
On Fri, 22 Aug 2008 11:42:03 +0200, Diez B. Roggisch wrote:
> It's amazing. I didn't analyse this properly, but IMHO this issue is the
> single most asked question (or rather the effects in produces) on this list.
>
> Maybe we should get *really* explicit in
>
> http://docs.python.org/tut/node6.h
On Fri, 22 Aug 2008 11:41:18 +0200, Bart van Deenen wrote:
> Thanks all for your answers. I figured your solution already, but now I
> understand where the behavior is from. One question remains: can I find my
> parameter 'l' somewhere? I looked in a lot of objects, but couldn't find it.
YOURFU
Bart van Deenen a écrit :
(ot : please don't top post - corrected)
[EMAIL PROTECTED] wrote:
On Aug 22, 11:13 am, Bart van Deenen
<[EMAIL PROTECTED]> wrote:
# function def X(l=[]): l.append(1) print l
# first call of X X() [1]
#second call of X X() [1, 1]
Where does the list parameter 'l' li
Wojtek Walczak schrieb:
On Fri, 22 Aug 2008 11:13:52 +0200, Bart van Deenen wrote:
I've stumbled onto a python behavior that I don't understand at all.
...
Does anyone have any pointers to the language documentation where this behavior
is described?
Yes, it's documented in FAQ:
http://www.
Hi
Thanks all for your answers. I figured your solution already, but now I
understand where the behavior is from. One question remains: can I find my
parameter 'l' somewhere? I looked in a lot of objects, but couldn't find it.
Thanks
Bart.
[EMAIL PROTECTED] wrote:
> On Aug 22, 11:13 am, Bar
On Fri, 22 Aug 2008 11:13:52 +0200, Bart van Deenen wrote:
> I've stumbled onto a python behavior that I don't understand at all.
...
> Does anyone have any pointers to the language documentation where this
> behavior is described?
Yes, it's documented in FAQ:
http://www.python.org/doc/faq/gener
On Aug 22, 11:13 am, Bart van Deenen
<[EMAIL PROTECTED]> wrote:
> Hi all.
>
> I've stumbled onto a python behavior that I don't understand at all.
>
> Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
>
> # function
> def X(l=[]):
> l.append(1)
> print l
>
> # first call of X
> X()
> [1]
>
> #
Hi all.
I've stumbled onto a python behavior that I don't understand at all.
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
# function
def X(l=[]):
l.append(1)
print l
# first call of X
X()
[1]
#second call of X
X()
[1, 1]
Where does the list parameter 'l' live between the two succe
11 matches
Mail list logo