Can local function access local variables in main program?

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Sun Nov 4 02:03:59 CET 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