2.2 features

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Wed Aug 1 13:36:05 EDT 2001


Wed, 01 Aug 2001 09:15:27 -0700, Paul Prescod <paulp at ActiveState.com> pisze:

> Second, I think that this might be worth adding new syntax for one
> reason. The current syntax for exception-type trapping is extremely
> error prone and nasty and it is essentially the same problem. I
> could imagine:
> 
> try:
>     foo()
> except exc isa OverflowError, ZeroDivisionError:
>     pass

Instead of commas an operator could be used which produces an object
whose __contains__ tests whether the given object belongs to either
of arguments. Obvious candidates are | or +, so
    try:
        foo()
    except OverflowError | ZeroDivisionError:
        pass
works and
    if obj in (int | float)
works using the same mechanism. Or maybe with + instead of |.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list