Steve Holden <[EMAIL PROTECTED]> wrote: > greg wrote: > > 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. > > > The idea is right, but the detail is completely wrong. > > basestring is a *type*. > > >>> basestring > <type 'basestring'> > > It's the base class of which both str and unicode are subclasses.
I believe it used to be a tuple back in Python 2.2 (sorry, don't have a Python 2.2 installation to check this right now). Alex -- http://mail.python.org/mailman/listinfo/python-list