Re: default method parameter behavior

2008-04-02 Thread Primoz Skale
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I ran into a similar situation like the following (ipython session). > Can anyone please explain why the behavior? > Thanks in advance. > > In [11]: def foo(b=[]): > : b.append(3) > : return b > : > > In [12]:

Re: default method parameter behavior

2008-04-02 Thread Jerry Hill
On Wed, Apr 2, 2008 at 3:59 PM, <[EMAIL PROTECTED]> wrote: > I ran into a similar situation like the following (ipython session). > Can anyone please explain why the behavior? http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects Since you got bitten by this, you

Re: default method parameter behavior

2008-04-02 Thread Konstantin Veretennicov
On Wed, Apr 2, 2008 at 10:59 PM, <[EMAIL PROTECTED]> wrote: > I ran into a similar situation like the following (ipython session). > Can anyone please explain why the behavior? Of course. >From http://docs.python.org/ref/function.html: Default parameter values are evaluated when the function def