Blog post where someone used Python quirks to evaluate false == true
-
wrote last edited by [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 astrue
? 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"
-
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 astrue
? 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"
I feel like you hear fuckery like that more in JavaScript.
-
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 astrue
? 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"
Maybe they did "False is True" because they're both the same Python object?
-
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 astrue
? 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"
wrote last edited by [email protected]Python doesn't have
true
orfalse
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.
-
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 astrue
? 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"
-
Python doesn't have
true
orfalse
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.
This changed in 3.0 to my knowledge.
Ref: https://wiki.python.org/moin/Python3.0#f -
Yes! Thanks
-
This changed in 3.0 to my knowledge.
Ref: https://wiki.python.org/moin/Python3.0#fwrote last edited by [email protected]That change is about
True
andFalse
, nottrue
andfalse
. If OP was thinking of the former pair, it would seem my "different identifiers" guess was correct. -
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 astrue
? 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"
wrote last edited by [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
-
Maybe they did "False is True" because they're both the same Python object?
I just checked and they aren't.
-
I just checked and they aren't.
wrote last edited by [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)
-
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)
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.
-
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.
I really need to stop trusting how durable this language is.
-
I feel like you hear fuckery like that more in JavaScript.
-
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
God I hated that about Python. Why tf we capitalizing
True
andFalse
? -
God I hated that about Python. Why tf we capitalizing
True
andFalse
?all builtin constants are capitalised.
-
God I hated that about Python. Why tf we capitalizing
True
andFalse
?They are constants, like None, which has always been around.
-
all builtin constants are capitalised.
wrote last edited by [email protected]All… five of them!
The other 7 are all lowercase. (One of you ignore site)
-
All… five of them!
The other 7 are all lowercase. (One of you ignore site)
yeah but dunders usually aren't included in counts
-
all builtin constants are capitalised.
And they also don't follow the conventions for constants otherwise, which are all caps.