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

Gregory P. Smith greg at krypto.org
Sat Oct 12 00:05:17 CEST 2013


On Fri, Oct 11, 2013 at 11:41 AM, Glenn Linderman <v+python at g.nevcal.com>wrote:

>  On 10/11/2013 10:19 AM, Eric V. Smith wrote:
>
> On 10/11/2013 12:43 PM, Barry Warsaw wrote:
>
>  On Oct 11, 2013, at 06:27 PM, Georg Brandl wrote:
>
>
>  Maybe to fit in with other verb-like APIs used as context managers:
> it's open() not opened().
>
>  open() predates context managers, but maybe we need a new convention.
>
> with ignore(FileNotFoundError):
>
> vs
>
> with ignored(FileNotFoundError):
>
> To me anyway, the latter sounds better.
>
>  I'm still -0, and maybe now -1 on the idea, mostly because it encourages
> an anti-pattern.
>
> But, to continue to paint the shed, shouldn't it be "ignoring", to match
> "closing"?
>
>
> Seriously, "with" is the wrong spelling for this using.  It should be
>
> while ignorning(FileNotFoundError)
>
> Insistence on using "with" for the anti-pattern, and proper English, would
> require:
>
> with ignorance_of(FileNotFoundError)
>

I was thinking more along the lines of:

with no_chance_in_hell_of_seeing(FileNotFoundError):

but seriously, we have plenty of antipattern enablers in the language and
standard library itself.  contextlib.ignore vs ignored vs all of these
others isn't a big deal to me.  Just document it as not recommended for
most things and let people shoot themselves if they've used "with
contextlib.ignored(Documentation):" while writing code.

I don't care what it is called and I think it is fine to have in contextlib.

I'm unlikely to use it anytime soon as I don't have a 3.4+ only code base.
Though suspect I could re-factor code to this in a few places within 3.4's
Lib/subprocess.py.

-gps
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20131011/0365cf15/attachment.html>


More information about the Python-Dev mailing list