Need help with "global" variables

William Park opengeometry at yahoo.ca
Sun Jul 15 11:13:44 EDT 2001


On Sun, Jul 15, 2001 at 03:00:46AM +0000, Pugsley wrote:
> def foo(arg1, arg2):
> 	global bar1, bar2, bar3,             etc.
> 	result= bar1+bar2+bar3+ arg1+arg2
> 	return result

Put 'bar1', 'bar2', and 'bar3' in a separate module, and import where
you need them.  Then, you only need 'global' statements to change their
values; you don't need it to access them.

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc.




More information about the Python-list mailing list