Loop exception catching
stv
stvsmth at gmail.com
Mon Jan 23 21:02:37 EST 2006
I'm just learning Python myself, but I just saw an example of
something similar. Not sure if this is what you're looking for, but
while 1:
try:
x=input('>')
except Exception, e:
print 'Problems: ', e
else:
break
The else clause is executed UNLESS something is caught.
The example is from Magnus Lie Hetland's "Beginning Python." Sorry if
this is too basic, but it seems to fit.
--stv
> I tryed this but to no
> avail:
>
> try:
> x = input("> ")
> except SyntaxError:
> while SyntaxError:
> print "Please enter only the number beside your choice"
> print
> x = input("> ")
More information about the Python-list
mailing list