By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,095 Members | 1,586 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,095 IT Pros & Developers. It's quick & easy.

stop()/_quit()

P: n/a
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.91 c
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
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Thomas Philips" <tk****@hotmail.com> wrote in message
news:b4**************************@posting.google.c om...
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?


Ummm, the error message might be a clue -- you could try *defining* _quit.

Or, you could use the standard library function sys.exit(), making sure you
import sys first.
--
I don't actually read my hotmail account, but you can replace hotmail with
excite if you really want to reach me.
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.