Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #24890
| Date | 2012-07-05 12:06 +1000 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: 2 + 2 = 5 |
| References | <4FF4E239.8060603@cs.wisc.edu> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1806.1341454467.4697.python-list@python.org> (permalink) |
On 04Jul2012 19:39, Evan Driscoll <driscoll@cs.wisc.edu> wrote: | 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. Yeah, I was thinking that too. Because all parameters were pass-by-reference in early fortran IIRC. You could, for example, set pi to 3. -- Cameron Simpson <cs@zip.com.au> If I have seen farther than others, it is because I was standing on the shoulders of giants. - Isaac Newton If I have not seen as far as others, it is because giants were standing on my shoulders. - Hal Abelson In computer science, we stand on each other's feet. - Brian K. Reed
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: 2 + 2 = 5 Cameron Simpson <cs@zip.com.au> - 2012-07-05 12:06 +1000
csiph-web