Tim Chase <[EMAIL PROTECTED]> wrote:

> This will return true for both regular strings and for unicode 
> strings.  If that's a problem, you can use
> 
> >>> import types
> >>> isinstance("hello", types.StringType)
> True
> >>> isinstance(u"hello", types.StringType)
> False
> >>> isinstance("hello", types.UnicodeType)
> False
> >>> isinstance(u"hello", types.UnicodeType)
> True
> 
> ...or, if you don't want to qualify them with "types." each time, 
> you can use
> 
> >>> from types import StringType, UnicodeType
> 
> to bring them into the local namespace.

They already are in the builtin namespace under their more usual names of 
str and unicode respectively, so there is no need to import them, just use 
them:

>>> isinstance("hello", str)
True

... etc ...
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to