Still the __new__ hell ...

greg greg at cosc.canterbury.ac.nz
Tue Mar 20 02:34:23 CET 2007


Paulo da Silva wrote:
> As a relatively inexperient
> in python, how could I know that a 'string' is an instance of
> basestring?

   isinstance(x, basestring)

This works because basestring is defined as the
tuple (str, unicode) and isinstance accepts a
tuple of types as well as just a single type.

--
Greg



More information about the Python-list mailing list