[Python-ideas] PEP-3151 pattern-matching

Greg Ewing greg.ewing at canterbury.ac.nz
Thu May 19 00:13:09 CEST 2011


Devin Jeanpierre wrote:
> On Wed, May 18, 2011 at 6:07 AM, dag.odenhall at gmail.com
> <dag.odenhall at gmail.com> wrote:
> 
>>except IOError(32):  # isinstance IOError and .args == (32,)
>>   ...
> 
> Unfortunately, as described it wouldn't match IOError(32, 'Blah blah
> blah').

Also it's a bit magical -- normally one doesn't expect
Haskell-like pattern matching in Python.

Maybe something more explicit would be better:

   try:
     ...
   except IOError as e with e.errno == 32:
     ...

-- 
Greg



More information about the Python-ideas mailing list