global variables - how??

Daley, MarkX markx.daley at
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.


a = [Vorpal]
b = [Bunny!]

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

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


-----Original Message-----
From: William Park [mailto:parkw at]
Sent: Wednesday, April 12, 2000 10:41 AM
To: python-list at
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
> modules?

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


> 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
> -- 

More information about the Python-list mailing list