2 + 2 = 5

Rhodri James rhodri at wildebst.demon.co.uk
Fri Jul 6 00:23:08 CEST 2012


On Wed, 04 Jul 2012 20:37:25 +0100, Paul Rubin <phr-2012 at nightsong.com>  
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.

Someone's been writing FORTRAN again :-)

-- 
Rhodri James *-* Wildebeest Herder to the Masses



More information about the Python-list mailing list