How robust is Python ?
Steve Holden
sholden at holdenweb.com
Fri Jan 12 16:21:47 EST 2001
"Donn Cave" <donn at u.washington.edu> wrote in message
news:93nh5u$9nk$1 at nntp6.u.washington.edu...
[exception handler query snipped]
>
> Why apart from that?
>
> I guess we've already covered the "try: continue" issue: "try: continue"
> just isn't supported (though the more useful "try: ... except: continue"
> does work.) Readable flow control inside a loop is very doable. It's
> hard for me to see that try: continue would really improve on that -
> on the contrary, continue is liable to detract from readability if it's
> used in conjunction with too many other flow control options. I think
> "goto" would be fun, too, but I can see why in some ways we're better
> off without it.
>
Yes, but there doesn't seem to be any inherent reason *why it shouldn't* be
supported in the future. It certainly isn't detected as a syntax error,
which would be going a bit far.
> But back to the subject, I would be interested in more concrete
> examples of what exceptions we're liable to catch in a case like that.
> I have used top level handlers, but only as basically an alternative to
> the traceback, not to resume execution. I think the initial proposal
> was to execute the program again from scratch after it exits, and it's
> pretty obvious what that's about. But after catching some random
> exception at the top of the program, I would be concerned that the
> program might be in a compromised state and not really fit to go back
> to work. And would that really catch the kind of lossage that could
> break a correctly written Python program, or do those things usually
> break the interpreter directly?
>
The reason *I* found for using this construct was, in pseudo-code:
#
# Handle billings by e-mail
#
for c in customer:
try:
read the database
zip up relevant files
formulate email with zip attached
try:
generate list of mail hosts
except KeyboardInterrupt:
raise
except:
continue
for host in hosts:
if known-bad-host:
log error
continue
send mail
...etc
AFAIR, Python complained because the continue was in the outer "try" even
though it was in the "except" of an inner "try", although it's along time
ago now so I could be wrong.
Whatever the case, I don't see why "continue" shouldn't be acceptable in
either suite, although I accept there may be some implementational
convenience to things the way they are now.
regards
Steve
More information about the Python-list
mailing list