Re: [Python-Dev] cpython: Rename contextlib.ignored() to contextlib.ignore().

2013年10月13日 05:56:42 -0700

On 13 October 2013 22:34, Antoine Pitrou <[email protected]> wrote:
> On 2013年10月13日 16:57:09 +1000
> Nick Coghlan <[email protected]> wrote:
>>
>> For the record, this thread did prompt me to consider the new construct
>> anew, but on reflection, I still consider it a reasonable addition to
>> contextlib.
>>
>> It substantially improves the simple cases it is intended to help with,
>> and, if anything, makes overly broad exception suppression *more* obviously
>> dubious (because the name of the construct doesn't match the consequences
>> for multi-line suites).
>
> Why? Anyone can still write "try ... except".
>
> The only sticking point for this construct is that it allows to save
> one or two lines in rather uncommon cases (because most of the time you
> should do something on an exception, not "ignore" it). The saving is
> not worth it.
>
> Basically instead of:
>
> try:
> # something
> except FooException:
> pass
>
> You write:
>
> from contextlib import ignore
> with ignore(FooException):
> # something
>
> There's actually more typing involved, and one more API to know about...
> It is just another case of those "one-liners" that we generally refrain
> from adding to the stdlib.
It meets my threshold for inclusion (albeit only just). Your objection
has been noted. I still do not agree. Now, can you please just let the
matter drop?
That's the way this works (unless you think this is such a disastrous
addition that you want to appeal to Guido to strip me of my
responsibilities as contextlib maintainer and go hunting for a new
one).
Regards,
Nick.
-- 
Nick Coghlan | [email protected] | Brisbane, Australia
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to