Can we make a local variable in a function as global variable???
collinstocks at gmail.com
Thu Apr 5 16:02:52 EDT 2007
Then name it something else. I tend to chose "this" because it is a
meaningless name that would not tend to be used for anything else. I would
have used "self", except that that tends to be used inside classes. My
inspiration for coming up with this is to make modules a little more like
classes. I suppose you wouldn't like me to post my own (somewhat buggy)
module that allows you to import modules as new type classes?
On 4/5/07, Steve Holden <steve at holdenweb.com> wrote:
> Collin Stocks wrote:
> > As for me, I find this problem annoying, but easy to solve. My solution
> > >>> 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
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list