Still the __new__ hell ...

greg greg at cosc.canterbury.ac.nz
Mon Mar 19 21:34:23 EDT 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