[Tutor] Global variables

Lee-Shanok, Bruce Bruce.Lee-Shanok@cognos.com
Thu, 20 Dec 2001 15:30:55 -0500


Hello all,

	I'm trying to declare a global variable to keep count of a value
without constantly passing it around. The problem I'm running into is =
that
it's not being recognized in any of my functions. The basic format is:

totalerrors =3D 0
def CheckErrors(statuscode):
	if statuscode < 0:
		totalerrors =3D totalerrors + 1
		print "Error with code",
		print statuscode

def RunTest():
	status =3D Func1()
	CheckErrors(status)
	status =3D Func2()
	CheckErrors(status)
	status =3D Func3()
	CheckErrors(status)
	status =3D Func4()
	CheckErrors(status)

RunTest()

.. is there any way for me to get totalerrors recognized? How does =
Python
determine where the scope of the variable ends?

Bruce Lee-Shanok
Access Manager
(613) 738-1338 ext 5764
Cognos, Ottawa=20
[Riverside, 4th Floor, E9]

Ce message peut contenir des informations prot=E9g=E9es et/ou =
confidentielles.
Si vous avez re=E7u ce mail par erreur ou si vous n'en =EAtes pas le
destinataire, il vous est interdit d'utiliser, de copier, de diffuser =
ou de
distribuer les pi=E8ces qui y sont jointes. Supprimez-le et notifiez
imm=E9diatement par e-mail la personne qui vous l'a envoy=E9e. Merci =
d'avance.


This message may contain privileged and/or confidential information.  =
If you
have received this e-mail in error or are not the intended recipient, =
you
may not use, copy, disseminate, or distribute it; do not open any
attachments, delete it immediately from your system and notify the =
sender by
e-mail promptly that you have done so.  Thank You.