[Python-ideas] PEP-3151 pattern-matching
dag.odenhall at gmail.com
dag.odenhall at gmail.com
Thu May 19 10:33:11 CEST 2011
On 19 May 2011 00:13, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> 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:
> ...
Then we're back where we started in which case I prefer 'if' as the keyword.
More information about the Python-ideas
mailing list