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

Ethan Furman ethan at stoneleaf.us
Sun Oct 13 01:30:30 CEST 2013


On 10/12/2013 03:27 PM, Raymond Hettinger wrote:
>
> When you ask someone to describe what
> "try: f() except SomeException: pass" does,
> they will say that it ignores the exception.

And they would be right in that case.


> FWIW, I presented this to 2500+ people in the keynote
> at the 2013 U.S. Pycon and have received favorable feedback.

Were you only displaying the same short form above?  Or did you show some with many lines of code inside the with block? 
  If you didn't, is that because it's a bad idea?

Compare:

     try:
         f()
         g()
         h()
     except SomeException:
         pass

and

     with contextlib.ignore(SomeException):
         f()
         g()
         h()

What's the difference?  The difference is that it is far less obvious that g() and h() may never run.  And if 
SomeException is stopping g() and h() from running, it is most certainly *not* being ignored.

For the record, I am no longer opposed to this context manager, only to its name.


> Please don't join Antoine's opposition to my every contribution.

Don't worry, I argue with him, too.  ;)  And I don't oppose your every contribution (nor his), and I'm pretty sure he 
doesn't either.


> The incessant sniping is demoralizing.

You mean like having you state your opposition to a PEP, then having you request to be the PEP delegate, and then having 
your first few comments show clearly that you have neither followed the thread very closely to that point nor even read 
the PEP?

All that aside, Python is a group project.  It's as good as it is because when someone sees something that doesn't make 
sense, (s)he asks about it.  So it seems there are two good courses of action in these situations:  1) realize something 
is not as clear as it could be, so make a code change and/or a doc change; or 2) take a moment and share your knowledge 
so others can learn.  Complaining is not productive.

--
~Ethan~


More information about the Python-Dev mailing list