Still the __new__ hell ...
Steve Holden
steve at holdenweb.com
Mon Mar 19 23:04:09 EDT 2007
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.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings http://holdenweb.blogspot.com
More information about the Python-list
mailing list