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

Collin Stocks collinstocks at gmail.com
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 gmail.com> 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
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070405/98dcb315/attachment.html>


More information about the Python-list mailing list