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/2014-February/132630.html below:

[Python-Dev] PEP 463: Exception-catching expressions

[Python-Dev] PEP 463: Exception-catching expressions [Python-Dev] PEP 463: Exception-catching expressionsEthan Furman ethan at stoneleaf.us
Sat Feb 22 02:28:30 CET 2014
On 02/21/2014 05:21 PM, Steven D'Aprano wrote:
> On Sat, Feb 22, 2014 at 01:15:13PM +1300, Greg Ewing wrote:
>>
>> With an except expression, it could be written:
>>
>>     result = computation(int(arg)
>>        except ValueError: abort("Invalid int"))
>
> Nice example! Except I'd lay the code out a bit better to emphasise
> which part is being guarded:
>
>      result = computation(
>                   int(arg) except ValueError: abort("Invalid int")
>                   )
>
> Actually, not quite so nice as I first thought, since you're relying on
> the side-effects of abort() rather than returning a value.

Think of it rather as transforming the exception to be more useful.

--
~Ethan~
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