def __rmul__(self, other):
value = super(newint, self).__rmul__(other)
if isint(value):
return newint(value)
elif value is NotImplemented:
return other * long(self)
return value
python类isint()的实例源码
def __lshift__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for <<: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__lshift__(other))
def __mul__(self, other):
value = super(newint, self).__mul__(other)
if isint(value):
return newint(value)
elif value is NotImplemented:
return long(self) * other
return value
def __rshift__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for >>: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__rshift__(other))
def __or__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for |: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__or__(other))
def __xor__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for ^: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__xor__(other))
def __mul__(self, other):
value = super(newint, self).__mul__(other)
if isint(value):
return newint(value)
elif value is NotImplemented:
return long(self) * other
return value
def __rmul__(self, other):
value = super(newint, self).__rmul__(other)
if isint(value):
return newint(value)
elif value is NotImplemented:
return other * long(self)
return value
def __lshift__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for <<: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__lshift__(other))
def __rshift__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for >>: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__rshift__(other))
def __or__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for |: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__or__(other))
def __xor__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for ^: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__xor__(other))
def __mul__(self, other):
value = super(newint, self).__mul__(other)
if isint(value):
return newint(value)
elif value is NotImplemented:
return long(self) * other
return value
def __rmul__(self, other):
value = super(newint, self).__rmul__(other)
if isint(value):
return newint(value)
elif value is NotImplemented:
return other * long(self)
return value
def __lshift__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for <<: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__lshift__(other))
def __rshift__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for >>: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__rshift__(other))
def __or__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for |: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__or__(other))
def __xor__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for ^: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__xor__(other))
def __mul__(self, other):
value = super(newint, self).__mul__(other)
if isint(value):
return newint(value)
elif value is NotImplemented:
return long(self) * other
return value
def __rmul__(self, other):
value = super(newint, self).__rmul__(other)
if isint(value):
return newint(value)
elif value is NotImplemented:
return other * long(self)
return value
def __lshift__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for <<: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__lshift__(other))
def __rshift__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for >>: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__rshift__(other))
def __or__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for |: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__or__(other))
def __xor__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for ^: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__xor__(other))
def __mul__(self, other):
value = super(newint, self).__mul__(other)
if isint(value):
return newint(value)
elif value is NotImplemented:
return long(self) * other
return value
def __rmul__(self, other):
value = super(newint, self).__rmul__(other)
if isint(value):
return newint(value)
elif value is NotImplemented:
return other * long(self)
return value
def __lshift__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for <<: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__lshift__(other))
def __rshift__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for >>: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__rshift__(other))
def __or__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for |: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__or__(other))
def __xor__(self, other):
if not isint(other):
raise TypeError(
"unsupported operand type(s) for ^: '%s' and '%s'" %
(type(self).__name__, type(other).__name__))
return newint(super(newint, self).__xor__(other))