On 7/4/2012 14:37, Paul Rubin wrote:
> I just came across this (https://gist.github.com/1208215):
>
> import sys
> import ctypes
> pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5))
> five = ctypes.cast(id(5), pyint_p)
> print(2 + 2 == 5) # False
> five.contents[five.contents[:].index(5)] = 4
> print(2 + 2 == 5) # True (must be sufficiently large values of 2 there...)
>
> Heh. The author is apparently anonymous, I guess for good reason.
Probably just nostalgic for old Fortran, which, supposedly, allowed you
to change the values of literals by passing them to a function by
reference and then modifying the value.
Evan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -
http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJP9OJBAAoJEAOzoR8eZTzgPyQH/RYRdhNWV7XjjAg4SgNjt3wj
a0KSrKHg8TPKb2Sbj6M+t09UzE6dvwQMpUuO6oviue4pUgrPa9 E0OK7TuWYi/3AA
J5GoC8xoWuy1t9+7Zu/fBC5ikuwPmDNOLhP0WgPCCdS35EZbNPvVg7FpvsidXeYZ
aFUFYi5VvJFmCPIGHFLqsomljMkavOde2ZtuPXSPgp4cBkb0sR xsMebN9xPjRWO9
5Sb6hchtwYZznJpc19WWCMSnIY+Ug30jsdP09dlr8SQf+PalOy BJbM9BoSaQ9NCG
ctFB/wDO6zamzr/Ba4vEA+9I6b4hsnjFe6l+1hlUgKBTxfbRqYoA4x6DGoz2Nb0=
=MvhR
-----END PGP SIGNATURE-----