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


Groups > comp.lang.python > #24888

Re: 2 + 2 = 5

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <driscoll@cs.wisc.edu>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'sys': 0.05; 'subject: + ': 0.07; 'url:github': 0.09; 'cc:addr:python-list': 0.10; 'passing': 0.15; 'value.': 0.15; '(must': 0.16; 'filename:fname piece:signature': 0.16; 'literals': 0.16; 'reason.': 0.16; 'which,': 0.16; 'wrote:': 0.17; 'pfxlen:0': 0.17; 'import': 0.21; 'ctypes': 0.22; 'modifying': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'paul': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'values': 0.26; 'guess': 0.27; 'probably': 0.29; 'function': 0.30; 'false': 0.35; 'skip:f 40': 0.35; 'received:192.168.0': 0.35; 'author': 0.37; 'subject:: ': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'heh.': 0.84
Date Wed, 04 Jul 2012 19:39:21 -0500
From Evan Driscoll <driscoll@cs.wisc.edu>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1
MIME-Version 1.0
To Paul Rubin <phr-2012@nightsong.com>
Subject Re: 2 + 2 = 5
References <7x7guj2u8a.fsf@ruckus.brouhaha.com>
In-Reply-To <7x7guj2u8a.fsf@ruckus.brouhaha.com>
X-Enigmail-Version 1.4.1
Content-Type multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigDBC70ADF71BA56CC7B6C0E7A"
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1804.1341448814.4697.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1341448814 news.xs4all.nl 6876 [2001:888:2000:d::a6]:40739
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:24888

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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


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


Thread

Re: 2 + 2 = 5 Evan Driscoll <driscoll@cs.wisc.edu> - 2012-07-04 19:39 -0500

csiph-web