Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24877

Re: 2 + 2 = 5

Date 2012-07-05 00:45 +0200
From Thomas Jollans <t@jollybox.de>
Subject Re: 2 + 2 = 5
References <7x7guj2u8a.fsf@ruckus.brouhaha.com>
Newsgroups comp.lang.python
Message-ID <mailman.1799.1341441946.4697.python-list@python.org> (permalink)

Show all headers | View raw


On 07/04/2012 09:37 PM, 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.
> 

I'm reminded of the swap(a,b) function I wrote a couple of years back.

http://blog.jollybox.de/archives/62-python-swap

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: 2 + 2 = 5 Thomas Jollans <t@jollybox.de> - 2012-07-05 00:45 +0200

csiph-web