mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-17 01:51:39 +09:00
21 lines
950 B
Python
21 lines
950 B
Python
x = 5
|
|
x.__init__(6)
|
|
assert x == 5
|
|
|
|
assert int.__doc__ == "int(x=0) -> integer\nint(x, base=10) -> integer\n\nConvert a number or string to an integer, or return 0 if no arguments\nare given. If x is a number, return x.__int__(). For floating point\nnumbers, this truncates towards zero.\n\nIf x is not a number or if base is given, then x must be a string,\nbytes, or bytearray instance representing an integer literal in the\ngiven base. The literal can be preceded by '+' or '-' and be surrounded\nby whitespace. The base defaults to 10. Valid bases are 0 and 2-36.\nBase 0 means to interpret the base from the string as an integer literal.\n>>> int('0b100', base=0)\n4"
|
|
|
|
class A(int):
|
|
pass
|
|
|
|
x = A(7)
|
|
assert x == 7
|
|
assert type(x) is A
|
|
|
|
assert int(2).__bool__() == True
|
|
assert int(0.5).__bool__() == False
|
|
assert int(-1).__bool__() == True
|
|
|
|
assert int(0).__invert__() == -1
|
|
assert int(-3).__invert__() == 2
|
|
assert int(4).__invert__() == -5
|