Does anyone remember an old blog post where someone used various Python language hacks to override boolean primitives, such that the statement false == true evaluated as true? I’m 90% sure it was python, but maybe it was some other language.

I’ve been looking for that post recently, but haven’t had any luck.

Thanks to antagonistic for finding it! I guess it was less of an “exploit”, and more of a “please don’t touch the loaded foot-gun”

  • @solrize@lemmy.ml
    link
    fedilink
    12
    edit-2
    13 days ago

    The builtin names are True and False and they became keywords a while back. true and false are just ordinary variables that you can set to whatever you want.

    Meanwhile, in Forth:

    : 2 3 ; \ define 2 as 3
    2 2 + .  6 ok   \ shows that 2+2 is now 6
    
  • who
    link
    fedilink
    English
    4
    edit-2
    13 days ago

    Python doesn’t have true or false keywords, nor any other primitives by those names.

    So either you’re thinking of a different language, or different identifiers, or someone assigned equal values to variables with those names and then blogged about it.

  • Kairos
    link
    fedilink
    313 days ago

    Maybe they did “False is True” because they’re both the same Python object?

      • Kairos
        link
        fedilink
        3
        edit-2
        13 days ago

        Maybe they defined them as variable names instead?

        Or they could have just changed the language. Do you remember them compiling or editing C? (Python is usually run on cpython)

        • @solrize@lemmy.ml
          link
          fedilink
          513 days ago

          True is False gives false in Python 2.7.18 as well as 3.x. But, in 2.x, they aren’t keywords, so you can say True=False=5 and then they are both the same object.

          • Kairos
            link
            fedilink
            313 days ago

            I really need to stop trusting how durable this language is.