[Python-ideas] except expression
Rob Cliffe
rob.cliffe at btinternet.com
Thu Feb 20 17:42:48 CET 2014
On 20/02/2014 15:23, Alexander Belopolsky wrote:
>
> On Thu, Feb 20, 2014 at 9:46 AM, Rob Cliffe <rob.cliffe at btinternet.com
> <mailto:rob.cliffe at btinternet.com>> wrote:
>
>
>
> I also find it disturbing that people are actually considering
> to use this expression form as a way to do quick&dirty suppression
> of exceptions.
>
> This is a relatively common construction (as a survey of my own
> small codebase indicates). Quick, yes. How dirty it is depends
> entirely on context, (and how readable it can be made) and is up
> to the programmer's judgment.
>
>
> Isn't it what contextlib.suppress() [1] was invented for? Do we need
> yet another way to express the same?
Well maybe. I have never learned about context managers and know
nothing about them. And without some other incentive, rather than make
the effort, I will stick with the tried and trusted "try ... except ...
finally" workhorse which is built into the language and which I do
understand.
>
> http://docs.python.org/3.4/library/contextlib.html#contextlib.suppress
>
> No virus found in this message.
> Checked by AVG - www.avg.com <http://www.avg.com>
> Version: 2012.0.2247 / Virus Database: 3705/6609 - Release Date: 02/20/14
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140220/a3e6e640/attachment.html>
More information about the Python-ideas
mailing list