global variables

M.E.Farmer mefjr75 at hotmail.com
Wed Feb 2 19:01:13 EST 2005


alex wrote:
> Hi,
>
> is it possible to create 'global' variables that can be seen in all
> other classes?
>
> Alex
Hello,
What about using a class?

Py> class globalVar:
...    pass

Py> globals = globalVar()

Now you can assign 'variables' to it.
And use it anywhere you need it.

Py> globals.image_height = (255,777)
Py> globals.image_mode = 'RGB'
Py> globals.image_names = ['this.jpg', that.jpg']
etc...
hth, 
M.E.Farmer




More information about the Python-list mailing list