[Python-Dev] On suppress()'s trail blazing (was Re: cpython: Rename contextlib.ignored() to contextlib.ignore()) (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Fri Oct 18 01:35:23 CEST 2013
- Previous message: [Python-Dev] On suppress()'s trail blazing (was Re: cpython: Rename contextlib.ignored() to contextlib.ignore())
- Next message: [Python-Dev] On suppress()'s trail blazing (was Re: cpython: Rename contextlib.ignored() to contextlib.ignore())
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 18 Oct 2013 06:59, "Xavier Morel" <catch-all at masklinn.net> wrote:
On 2013-10-17, at 22:11 , Ethan Furman wrote: > On 10/17/2013 01:03 PM, Terry Reedy wrote: >> >> class suppress: >> def init(self, *exceptions): >> self.exceptions = exceptions >> def exit(self, etype, eval, etrace): >> return etype in self.exceptions > > This fails when etype is a subclass of the exceptions, as mentioned in the original issue. That's fixed by using
issubclass
and does not infirm Terry's point does it?
Yeah, it looks like it's worth switching to the class based implementation in this case. I guess I'm too accustomed to that being the more complex alternative, as I hadn't even tried it :)
Cheers, Nick.
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20131018/edc51e71/attachment.html>
- Previous message: [Python-Dev] On suppress()'s trail blazing (was Re: cpython: Rename contextlib.ignored() to contextlib.ignore())
- Next message: [Python-Dev] On suppress()'s trail blazing (was Re: cpython: Rename contextlib.ignored() to contextlib.ignore())
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]