Can we make a local variable in a function as global variable???

Collin Stocks collinstocks at
Thu Apr 5 20:30:33 CEST 2007

As for me, I find this problem annoying, but easy to solve. My solution is:

>>> this=__import__(__name__)

To  set global variable spam to 4, I say:

>>> this.spam=4

This always works, and is much more convenient than:

>>> global spam
>>> spam=4

and then worry about local variables also named spam.

On 5 Apr 2007 02:19:34 -0700, sairam <sai438 at> wrote:
> I have some local variables defined in one method and Can I make those
> variables as global variables? If so , can any one explain me how can
> I do that
> Thanks,
> Sairam
> --
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list