A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-March/087784.html below:

[Python-Dev] suggestion for try/except program flow

[Python-Dev] suggestion for try/except program flow [Python-Dev] suggestion for try/except program flowNick Coghlan ncoghlan at gmail.com
Fri Mar 27 13:41:15 CET 2009
Hrvoje Niksic wrote:
> How about:
> 
> try:
>     ... code that can raise Thing or another exception ...
> except Exception, e:
>     if isinstance(e, Thing):
>         # handle thing
>     # generic exception handling

That is indeed the idiomatic way of handling the original poster's use
case without nesting a second try block.

Any proposals for new dedicated syntax should probably go to
python-ideas rather than here though. (It's a rare enough use case that
I don't like the original poster's chances of getting much support for
changes though)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4