[Python-Dev] Need a way to test for 8-bit-or-unicode-string

Jeremy Hylton jeremy@zope.com
Fri, 5 Oct 2001 11:47:11 -0400 (EDT)


>>>>> "FLD" == Fred L Drake, <fdrake@acm.org> writes:

  FLD>     for t in ListType, TupleType, ...:
  FLD>         if isinstance(obj, t):
  FLD>             break
  FLD>     else:
  FLD>         raise Exception('no match!')

Or:

try:
    raise obj
except (ListType, TupleType):
    pass
except:
    raise TypeError, ...

with-apologies-to-tim-ly y'rs,
Jeremy