[Python-bugs-list] Blank except block fails in try statement
(PR#60)
Dan Wolfe
wolfeman@apple.com
Mon, 23 Aug 1999 09:39:15 -0700
Hi Skip,
Thanks for the answer. Unfortunately, this little nugget is not
mentioned in Learning Python or Programming Python, or the online
documentation - at least not where I can find it. :-) Now that I
know what to look for, it does appear in Programming Python example
code pg 853 but doesn't get metioned in the text.....
Bottom line, who can I email to make sure that this nugget get's in
the documentation?
- Dan - just a python newbie with a taste for QA ....
At 7:25 AM -0500 8/22/99, Skip Montanaro wrote:
> Dan> When you have an empty except: block in a try statement, both
> Dan> MacPython 1.5.2b1 and Linux Python 1.5.2 report that you have
> Dan> invalid syntax.
>
>That's neither a bug nor a feature. It's a syntax error. Blocks can't be
>empty, hence the pass statement's raison d'etre:
>
> try:
> print "this is a test"
> raise(error)
> except:
> pass
> else:
> print "pleasent dreams"
>
> Dan> The easiest way to fix this is by adding a single line to the empty
> Dan> exception block:
>
>And Bob's your uncle! ;-)
>
>Skip Montanaro | http://www.mojam.com/
>skip@mojam.com | http://www.musi-cal.com/~skip/
>847-971-7098 | Python: Programming the way Guido indented...