Can we make a local variable in a function as global variable???
steve at holdenweb.com
Thu Apr 5 21:16:25 CEST 2007
Collin Stocks wrote:
> 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.
That's truly horrible. And what if you have a local variable called "this"?
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings http://holdenweb.blogspot.com
More information about the Python-list