[Tutor] sys.exit() syntax error

Gerald Wann photonuv at kudos.net
Tue Apr 6 05:03:34 EDT 2004


Hi -

The answer to this is probably so trivial that i'll kick myself for 
asking... ;-)

i'm trying to use the sys.exit() function inside an error trap block and 
the interpreter keeps telling me there's a syntax error e.g.

import sys

try:
	open(file)
except: IOError
	print 'blah'
	print 'blah'
	sys.exit()

python doesn't like this... and says there's a syntax error at the 
sys.exit() line

however, when i dedent the sys.exit() call outside the except: block, it 
runs just fine, (except for the fact that it shuts the whole thing down ;-)

What am i missing here?

I'm using Komodo 2.5 IDE and python 2.2.3

TIA

Jerry




More information about the Tutor mailing list