this post was submitted on 15 Aug 2025
35 points (97.3% liked)

Programmer Humor

26747 readers
768 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

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"

top 20 comments
sorted by: hot top controversial new old
[–] Antagnostic@lemmy.world 22 points 1 month ago (1 children)
[–] solrize@lemmy.ml 12 points 1 month ago* (last edited 1 month ago) (1 children)

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.ch 3 points 1 month ago (2 children)

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

[–] lime@feddit.nu 4 points 1 month ago (2 children)

all builtin constants are capitalised.

[–] RecallMadness@lemmy.nz 4 points 1 month ago* (last edited 1 month ago) (1 children)

All… five of them!

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

[–] lime@feddit.nu 2 points 1 month ago

yeah but dunders usually aren't included in counts

[–] squaresinger@lemmy.world 1 points 1 month ago (1 children)

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

[–] lime@feddit.nu 1 points 1 month ago

i think we're talking about different things.

[–] solrize@lemmy.ml 2 points 1 month ago

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

[–] ExperimentalGuy@programming.dev 8 points 1 month ago (1 children)

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

[–] who@feddit.org 4 points 1 month ago* (last edited 1 month ago) (1 children)

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.

[–] Antagnostic@lemmy.world 4 points 1 month ago (1 children)
[–] who@feddit.org 4 points 1 month ago* (last edited 1 month ago)

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.

[–] LodeMike@lemmy.today 3 points 1 month ago (1 children)

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

[–] solrize@lemmy.ml 5 points 1 month ago (1 children)

I just checked and they aren't.

[–] LodeMike@lemmy.today 3 points 1 month ago* (last edited 1 month ago) (1 children)

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 5 points 1 month ago (1 children)

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.

[–] LodeMike@lemmy.today 3 points 1 month ago

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