Can local function access local variables in main program?

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Sat Nov 3 21:03:59 EDT 2007


Pawel wrote:
> Is there any way to disable global for x? Something like that:
>>>> x = 12345
>>>> def foo():
> ...     global x
> ...     print x
> ...     noglobal(x)  # ???
> ...     x = 0        # now this is local x

Not really. Why don't you choose meaningful variable names? You
practically save nothing by using fewer names.

Regards,


Björn

-- 
BOFH excuse #423:

It's not RFC-822 compliant.




More information about the Python-list mailing list