in later versions.
"""
-import types
-
-StringType = types.StringType
-
-if hasattr(types, 'UnicodeType'):
- UnicodeType = types.UnicodeType
+try: unicode
+except NameError:
def is_String(obj):
- return type(obj) in (StringType, UnicodeType)
+ return isinstance(obj, str)
else:
def is_String(obj):
- return type(obj) is StringType
+ return type(obj) in (str, unicode)
class UserString:
def __init__(self, seq):
def __complex__(self): return complex(self.data)
def __hash__(self): return hash(self.data)
- def __cmp__(self, string):
+ def __cmp__(self, str):
if isinstance(string, UserString):
- return cmp(self.data, string.data)
+ return cmp(self.data, str.data)
else:
return cmp(self.data, string)
def __contains__(self, char):