Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. Blog post where someone used Python quirks to evaluate false == true

Blog post where someone used Python quirks to evaluate false == true

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
21 Posts 11 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A [email protected]

    This?

    C This user is from outside of this forum
    C This user is from outside of this forum
    [email protected]
    wrote last edited by
    #7

    Yes! Thanks

    1 Reply Last reply
    7
    • A [email protected]

      This changed in 3.0 to my knowledge.
      Ref: https://wiki.python.org/moin/Python3.0#f

      W This user is from outside of this forum
      W This user is from outside of this forum
      [email protected]
      wrote last edited by [email protected]
      #8

      That change is about True and False, not true and false. If OP was thinking of the former pair, it would seem my "different identifiers" guess was correct.

      1 Reply Last reply
      3
      • C [email protected]

        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"

        S This user is from outside of this forum
        S This user is from outside of this forum
        [email protected]
        wrote last edited by [email protected]
        #9

        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
        
        undefined@lemmy.hogru.chU 1 Reply Last reply
        11
        • L [email protected]

          Maybe they did "False is True" because they're both the same Python object?

          S This user is from outside of this forum
          S This user is from outside of this forum
          [email protected]
          wrote last edited by
          #10

          I just checked and they aren't.

          L 1 Reply Last reply
          1
          • S [email protected]

            I just checked and they aren't.

            L This user is from outside of this forum
            L This user is from outside of this forum
            [email protected]
            wrote last edited by [email protected]
            #11

            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)

            S 1 Reply Last reply
            1
            • L [email protected]

              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)

              S This user is from outside of this forum
              S This user is from outside of this forum
              [email protected]
              wrote last edited by
              #12

              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.

              L 1 Reply Last reply
              1
              • S [email protected]

                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.

                L This user is from outside of this forum
                L This user is from outside of this forum
                [email protected]
                wrote last edited by
                #13

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

                1 Reply Last reply
                0
                • E [email protected]

                  I feel like you hear fuckery like that more in JavaScript.

                  E This user is from outside of this forum
                  E This user is from outside of this forum
                  [email protected]
                  wrote last edited by
                  #14

                  Wat

                  1 Reply Last reply
                  7
                  • S [email protected]

                    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
                    
                    undefined@lemmy.hogru.chU This user is from outside of this forum
                    undefined@lemmy.hogru.chU This user is from outside of this forum
                    [email protected]
                    wrote last edited by
                    #15

                    God I hated that about Python. Why tf we capitalizing True and False?

                    lime@feddit.nuL S 2 Replies Last reply
                    3
                    • undefined@lemmy.hogru.chU [email protected]

                      God I hated that about Python. Why tf we capitalizing True and False?

                      lime@feddit.nuL This user is from outside of this forum
                      lime@feddit.nuL This user is from outside of this forum
                      [email protected]
                      wrote last edited by
                      #16

                      all builtin constants are capitalised.

                      R S 2 Replies Last reply
                      3
                      • undefined@lemmy.hogru.chU [email protected]

                        God I hated that about Python. Why tf we capitalizing True and False?

                        S This user is from outside of this forum
                        S This user is from outside of this forum
                        [email protected]
                        wrote last edited by
                        #17

                        They are constants, like None, which has always been around.

                        1 Reply Last reply
                        2
                        • lime@feddit.nuL [email protected]

                          all builtin constants are capitalised.

                          R This user is from outside of this forum
                          R This user is from outside of this forum
                          [email protected]
                          wrote last edited by [email protected]
                          #18

                          All… five of them!

                          The other 7 are all lowercase. (One of you ignore site)

                          lime@feddit.nuL 1 Reply Last reply
                          1
                          • R [email protected]

                            All… five of them!

                            The other 7 are all lowercase. (One of you ignore site)

                            lime@feddit.nuL This user is from outside of this forum
                            lime@feddit.nuL This user is from outside of this forum
                            [email protected]
                            wrote last edited by
                            #19

                            yeah but dunders usually aren't included in counts

                            1 Reply Last reply
                            1
                            • lime@feddit.nuL [email protected]

                              all builtin constants are capitalised.

                              S This user is from outside of this forum
                              S This user is from outside of this forum
                              [email protected]
                              wrote last edited by
                              #20

                              And they also don't follow the conventions for constants otherwise, which are all caps.

                              lime@feddit.nuL 1 Reply Last reply
                              0
                              • S [email protected]

                                And they also don't follow the conventions for constants otherwise, which are all caps.

                                lime@feddit.nuL This user is from outside of this forum
                                lime@feddit.nuL This user is from outside of this forum
                                [email protected]
                                wrote last edited by
                                #21

                                i think we're talking about different things.

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups