|
发表于 2018-11-18 20:36:34
|
显示全部楼层
class Nstr(str):
def __new__(cls, arg = ''):
if isinstance(arg, str) and arg:
a = arg.split(maxsplit = 1)
arg = len(a [0])
return str.__new__(cls, arg)
else:
print('Arguments\' type is wrong, must be string and length must at least one.')
def __lt__(self, other):
return int(self) < int(other)
def __le__(self, other):
return int(self) <= int(other)
def __eq__(self, other):
return int(self) == int(other)
def __ne__(self, other):
return int(self) != int(other)
def __gt__(self, other):
return int(self) > int(other)
def __ge__(self, other):
return int(self) >= int(other)
|
|