global variables - how??

Daley, MarkX markx.daley at intel.com
Wed Apr 12 14:10:45 EDT 2000


You can also assign them as lists instead of standard variables.  Then, when
you reference them in your modules, just use the first entry in the list.

e.g.

a = [Vorpal]
b = [Bunny!]

def eek():
	print a[0]
	print b[0]

I find this list usage quite useful.  Hope this helps!

Mark

-----Original Message-----
From: William Park [mailto:parkw at better.net]
Sent: Wednesday, April 12, 2000 10:41 AM
To: python-list at python.org
Subject: Re: global variables - how??


On Wed, Apr 12, 2000 at 07:28:37PM +0200, Anders Eggers-Krag wrote:
> how do I define a propper global variable that works in all functions in
all
> modules?

As far as I know, you can't.  You have to use 'global ...' inside all
your functions.

--William

> 
> I have tried simply
> defining one outside of any function in the main module,
> I have tried using the global keyword under the same cicumstances,
> but they are not even avialible inside of functions within the main
> module...
> 
> 
> --
> Anders Eggers - Krag
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list