What's the difference between:
isinstance(foo, types.StringType)
and
isinstance(foo, basestring)
?
For Python2: basestring
is the base class for both str
and unicode
, while types.StringType
is str
. If you want to check if something is a string, use basestring
. If you want to check if something is a bytestring, use str
and forget about types
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With