Re: Globals in nested functions

2007-06-21 Thread Neil Cerutti
On 2007-06-21, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > def f(): > a = 12 > def g(): > global a > if a < 14: > a=13 > g() > return a > > print f() > > This function raises an error. Is there any way to access the a > in f() from inside g(). > > I co

Re: Globals in nested functions

2007-06-21 Thread Stef Mientki
[EMAIL PROTECTED] wrote: > def f(): > a = 12 > def g(): > global a > if a < 14: > a=13 > g() > return a > > print f() > > This function raises an error. Is there any way to access the a in f() > from inside g(). > > I could find few past discussions on

Re: Globals in nested functions

2007-06-21 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > def f(): > a = 12 > def g(): > global a > if a < 14: > a=13 > g() > return a > > print f() > > This function raises an error. Is there any way to access the a in > f() from inside g(). Yes. Pass it to g when calling the latt

Re: Globals in nested functions

2007-06-21 Thread Duncan Booth
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > def f(): > a = 12 > def g(): > global a > if a < 14: > a=13 > g() > return a > > print f() > > This function raises an error. Is there any way to access the a in f() > from inside g(). > > I could find

Globals in nested functions

2007-06-21 Thread [EMAIL PROTECTED]
def f(): a = 12 def g(): global a if a < 14: a=13 g() return a print f() This function raises an error. Is there any way to access the a in f() from inside g(). I could find few past discussions on this subject, I could not find the simple answer wheth