Newbie problem: global variables
Geoff Gerrietts
geoff at gerrietts.net
Tue Apr 16 16:42:52 EDT 2002
Quoting Mirko Opitz (opm at hrz.tu-chemnitz.de):
> Hi,
>
> I've a small problem I need a variable which is present in all subfunctions
> an also in the main prog but I don't want do give it in the header of all
> the functions. Is there anyway to declaire it as Public or global like in
> other languages?
def funcy(arg):
global my_global
my_global = arg
def not_so_funcy():
global my_global
print my_global
funcy("spam")
no_so_funcy()
Do what you want?
--G.
--
Geoff Gerrietts <geoff at gerrietts dot net> http://www.gerrietts.net/
"If I were two-faced, would I be wearing this one?" --Abraham Lincoln
More information about the Python-list
mailing list