[snip]
>
> (Although, I'm not sure what you meant by "working" in the below case,
> since your example doesn't exit the interpreter.)
> [snip]
>
>
> try:
> f = file('somefile_you_have.txt','r')
> sys.exit(0)
>
> except IOError:
> print "You had an error on file input"
>
It would if you had a file named 'somefile_you_have.txt' in the same
working directory as your python interpreter is set to.
If you don't, the f = file( ... ) line will fail to find the file to
open for input, so it will throw an IOError and print out
"You had an error on file input"
If you do have such a file, the assignment to f will pass successfully,
sys.exit will throw a SystemExit, and the except block won't catch it
because it only catches IOErrors.
HTH,
-Luke
P.S. Please use the reply-all button so your replies go to the list and
not to me.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor