3 ms·
I thought this was pretty neat # WARNNG: never do this! id113 = id(113) iptr = IntStruct.from_address(id113) iptr.ob_digit = 4 # now Python's 113 cont
by adenadel 9y ago
I thought this was pretty neat
# WARNNG: never do this!
id113 = id(113)
iptr = IntStruct.from_address(id113)
iptr.ob_digit = 4 # now Python's 113 contains a 4!
113 == 4
And now since the proper value 113 doesn't exist you have to resort to the binary representation on your system to revert back to normal behavior
ctypes.cast(id113, ctypes.POINTER(ctypes.c_char))[3 * 8] = b'\x71'