[python-win32] 'exit is not defined'

Jacob Kruger jacobk at mailzone.co.za
Fri Jun 3 08:30:02 CEST 2011


What I'm doing is trying to open a text file, but if it's not there, then I tell the code to exit(), and while it works when running the source code using the python executable, after I have run the code through py2exe, and then try testing it, I get the following message:

Traceback (most recent call last):
File "mapData.py", line 39, in <module>
NameError: name 'exit' is not defined

The following is the actual little bit of code that's generating this after being py2exe'ed - the last line is the line number being mentioned above:

try:
	fData = open(sMapName + ".txt", "r")
except:
	fData = None
finally:
	if not bool(fData): print("invalid map name - " + sMapName + ".txt"); exit()


Any thoughts/ideas/alternative workarounds?

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'



More information about the python-win32 mailing list