Re: scope, function, mutable

2012-12-04 Thread Jussi Piitulainen
gusa...@gmail.com writes: > What is the appropriate definition for the following behavior in > Python 2.7 (see code below). > > Both functions have assignment in it (like "x = ") so I assume, that > x is a local variable in both functions. It's a local variable in both functions because it's a fo

Re: scope, function, mutable

2012-12-04 Thread Thomas Bach
Hi, On Tue, Dec 04, 2012 at 02:55:44PM +0400, gusa...@gmail.com wrote: > What is the appropriate definition for the following behavior in Python 2.7 > (see code below). It has something to do with mutability of lists and that Python passes around references and not the actual objects. > > def f

Re: scope, function, mutable

2012-12-04 Thread Steven D'Aprano
On Tue, 04 Dec 2012 14:55:44 +0400, gusarer wrote: > What is the appropriate definition for the following behavior in Python > 2.7 (see code below). > Both functions have assignment in it (like "x = ") so I assume, that x > is a local variable in both functions. Well, yes, but that's not why x is

scope, function, mutable

2012-12-04 Thread gusarer
Hi, What is the appropriate definition for the following behavior in Python 2.7 (see code below). Both functions have assignment in it (like "x = ") so I assume, that x is a local variable in both functions. Also I thought this rule doesn't depend on WHERE in this function we find the assignment.