global variable problem

Will Ware wware at world.std.com
Mon Jan 24 11:28:05 EST 2000


volumeregeling (volumeregeling at hotmail.com) wrote:
: I have the following :
: Debugging = 0
: def remote_debug():
:       Debugging = 1
: can you tell me how i can update the global variable from
: within a function ????  

Do this:

Debugging = 0
def remote_debug():
	global Debugging
	Debugging = 1

When a variable is used within a function definition, it is
global as long as you don't assign to it. If you assign to it,
Python assumes you want it to be local, and you must explicitly
declare it to be global. I forget why, but there is a reason
that this is a good thing.
-- 
   People say that everyone has a few skeletons in their closet. Not me.
   Well, not yet anyway. I mean, the bodies are still decomposing.
Will Ware		email: wware[at]world[dot]std[dot]com



More information about the Python-list mailing list