On 11/29/2017 01:02 PM, Barry Warsaw wrote:
I don’t know whether I like any of this <wink> but I think a more natural spelling would be:
val = name.strip()[4:].upper() except (AttributeError, KeyError) as -1
which could devolve into:
val = name.strip()[4:].upper() except KeyError as -1
or:
val = name.strip()[4:].upper() except KeyError # Implicit `as None`
Of all the proposed spellings for the idea, this one feels most "normal" to me, too (I'm -0 on the idea as a whole).
I would *not* add any spelling for an explicit bare-except equivalent. You would have to write:
val = name.strip()[4:].upper() except Exception as -1
Wouldn't that really need to be this instead, for a true 'except:' equivalence: val = name.strip()[4:].upper() except BaseException as -1 Tres. -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com