>
> One problem with short examples is they mask the reason for the code to
> be structured that way.
>
>
Couldn't agree more (I don't think I've ever written a nested function
outside a closure). I made the assumption that the OP wasn't asking about
closures based on his code samples. In hindsight
On 10/03/2012 01:54 AM, Demian Brecht wrote:
> On 12-10-02 07:26 PM, Dave Angel wrote:
>>
>> if you're stuck with Python2.x, you can use a mutable object for a, and
>> mutate it, rather than replace it. For example,
>>
>>
>> def foo():
>> a = [3]
>> def bar():
>> b=2
>>
On 12-10-02 07:26 PM, Dave Angel wrote:
if you're stuck with Python2.x, you can use a mutable object for a, and
mutate it, rather than replace it. For example,
def foo():
a = [3]
def bar():
b=2
a.append(b) #this mutates a, but doesn't assign it
prin
On 10/02/2012 10:03 PM, contro opinion wrote:
> code1
def foo():
> ... a = 1
> ... def bar():
> ... b=2
> ... print a + b
> ... bar()
> ...
> ...
foo()
> 3
>
> code2
def foo():
> ... a = 1
> ... def bar():
> ... b=2
> ... a = a + b