On Sun, Oct 13, 2013 at 1:01 PM, R. David Murray <rdmur...@bitdance.com> wrote:
> But the name hurts my brain

I did not think I would weigh in on this because Ramond's and Nick's
position seemed quite rational and the issue minor, but surprisingly
this thread does not seem to end.

The feature (*and* its name) is a fine solution for the problem that
it solves and is an improvement over status quo.

I find

with ignore(OSError):
     os.unlink(path)

much easier to read than

try:
   os.unlink(path)
except OSError:
   pass

Yes, this feature can be abused with multiple statements in the with
block, but so can try/except.   People who write code using contextlib
are expected to know that it is not a good idea to keep resources
longer than necessary and multiple unrelated statements within the
with block will raise a mental red flag.   It is also easy for
lint-like tools to warn about abuse of ignore().

I also believe that any of the proposed alternative names will make
canonical usage (such as in the unlink example above) harder to
understand.  Let's not try to improve readability of bad code at the
expense of good code.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
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