stop()/_quit()

Thomas Philips tkpmep at hotmail.com
Fri May 14 15:58:17 EDT 2004


I attempt to open a writeable file inside some nested loops, and want
my program to terminate cleanly with an error message if it cannot
find the file's path (e.g. directory does not exist). So I write

try: outFile = file(outFileName, "w")
except IOError:
   print "The output file",outFileName,"cannot be created."
   _quit()

but when I run the code in IDLE, I get 

The output file c:\python23\programs\Ford\PaLGUVMO20\PaLGUVMO20.91c
cannot be created.

Traceback (most recent call last):
  File "C:\Python23\Programs\ford1.py", line 109, in -toplevel-
    main()
  File "C:\Python23\Programs\ford1.py", line 66, in main
    _quit()
NameError: global name '_quit' is not defined

I've tried stop() instead of _quit(), with similar results. break does
not do the job - it just breaks out of the innermost loop and the
outer loops keep running. What's the fix?

Thomas Philips



More information about the Python-list mailing list