try:else: w/o except: - why not?
Manus Hand
manus at python.net
Mon Mar 31 18:53:13 EST 2003
I know that if you want to use else: on a try: block, you need to
specify one or more except: clauses. I guess my question is why
this should need to be.
Personally, I have cases where it would be nice to do this:
try:
# some code that may except
else:
# but if it didn't except, I want to do this
Instead of writing the code that way, I need to write this:
try:
# some code that may except
except:
# and if it does, then, okay, just ignore it
pass
else:
# but if it didn't except, I want to do this
I know it's a core language decision and therefore up to Guido,
but I am curious (Guido?) if there is something I am missing that
would make a simple try:else: construction (without requiring any
except: blocks) not make sense?
Manus
More information about the Python-list
mailing list