[Python-ideas] Bad code exceptions (was PEP-3151 pattern-matching)

Antoine Pitrou solipsis at pitrou.net
Fri Apr 8 21:09:29 CEST 2011


On Fri, 8 Apr 2011 11:32:39 -0700
Guido van Rossum <guido at python.org> wrote:
> 
> But honestly that wasn't my intended use case. I was thinking more
> along the lines of trying to catch OSError with a specific errno
> value:
> 
> except OSError as e if e.errno == errno.ENOTOBACCO:
>   logging.info('Pipe has no tobacco')

Given errno naming conventions, this should probably be errno.ENOTOB ;)

Regards

Antoine.





More information about the Python-ideas mailing list