How do I make a constant global variable in Python Please

Bill Scherer scherbi at bam.com
Mon Apr 17 17:56:43 CEST 2000


declare the variable as global inside the function you wish to use the
global variable, else you just create a new local variable of the same
name. eg:

foo = 1

def spam():
    #use the global foo
    global foo
    ...

def eggs():
    #this function has it's own foo
    foo = 2
    ...

OK?

-Bill

cmfinlay at magnet.com.au wrote:

> How do I make a constant global variable in Python Please.
> or just a constant.
> or just a global.
>
> I bought a Python Book. however I can't find this info in it.
>
> Please e-mail me at cmfinlay at magnet.com.au
> --
> http://www.python.org/mailman/listinfo/python-list







More information about the Python-list mailing list