Re: Default Argument Question

2008-10-29 Thread Benjamin Kaplan
On Wed, Oct 29, 2008 at 12:44 PM, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Chris Rebert a écrit : > (snip) > >> Note that the "accumulation" behavior of lists is considered an >> aberration >> > > By who ? > All the python newbies who don't read the tutorial and get tripped up by this.

Re: Default Argument Question

2008-10-29 Thread Bruno Desthuilliers
Chris Rebert a écrit : (snip) Note that the "accumulation" behavior of lists is considered an aberration By who ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Default Argument Question

2008-10-29 Thread Bruno Desthuilliers
Paulo J. Matos a écrit : Hi all, Going through the tutorial brought up a question. Consider the functions: def f(a, L=[]): L.append(a) return L print f(3) print f(9) print f(7) def f1(i = 0): i = i + 1 print i f1() f1() f1() f1() Since the f accumulates the values in L, I wa

Re: Default Argument Question

2008-10-29 Thread Chris Rebert
On Wed, Oct 29, 2008 at 9:14 AM, Paulo J. Matos <[EMAIL PROTECTED]> wrote: > Hi all, > > Going through the tutorial brought up a question. Consider the functions: > > def f(a, L=[]): >L.append(a) >return L > > print f(3) > print f(9) > print f(7) > > def f1(i = 0): >i = i + 1 >print

Default Argument Question

2008-10-29 Thread Paulo J. Matos
Hi all, Going through the tutorial brought up a question. Consider the functions: def f(a, L=[]): L.append(a) return L print f(3) print f(9) print f(7) def f1(i = 0): i = i + 1 print i f1() f1() f1() f1() Since the f accumulates the values in L, I was expecting to see i printi