[Freeipa-devel] Re: [PATCH] check for both str and unicode types
John Dennis
jdennis at redhat.com
Thu Feb 21 16:08:35 UTC 2008
Felix Schwarz wrote:
> Robert,
>
> Rob Crittenden wrote:
>> +def is_string(value):
>> + """Return True if value is an instance of str or unicode."""
>> + if (isinstance(value, str) or isinstance(value,unicode)):
>> + return True
>> + else:
>> + return False
>
> IMHO you should check for "isinstance(value, basestring)" which does
> the right thing (tm).
Yes, that's a good solution. Just for completeness if one is testing for
a type with pythons builtin types you can also use types.StringTypes
which contains both types.StringType and types.UnicodeType
--
John Dennis <jdennis at redhat.com>
More information about the Freeipa-devel
mailing list