Re: 2 + 2 = 5

Discussion in 'Python' started by Cameron Simpson, Jul 5, 2012.

  1. On 04Jul2012 19:39, Evan Driscoll <> 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 <>

    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
     
    Cameron Simpson, Jul 5, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page