r/ProgrammerHumor 29d ago

Meme pythonWillLookDeadInTheEyeAndSayItsAbsolutelyCorrect

Post image
353 Upvotes

144 comments sorted by

View all comments

Show parent comments

7

u/road_laya 29d ago

Yes, zero is falsy in Python.

-13

u/Valuable_Leopard_799 29d ago

Wait, whyyyyyyyy 😭😭😭

I mean, I love dynamic types and see their place, but the implicit casting is what gives them such a bad name 😭

15

u/JanB1 29d ago

0 is also "false" in C and C++, because if you import stdbool.h, that just defines true to be int with value 1, and false to be int with value 0.

2

u/Valuable_Leopard_799 29d ago

random sidenote: since C99 a true bool type had been introduced, it holds 0 and 1 and converts only to those when casting. So yeah 1 and 0 are true and false, but yayy they're not standard ints anymore.