this post was submitted on 17 Jan 2024
        
      
      680 points (98.9% liked)
      Programmer Humor
    27101 readers
  
      
      867 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
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
        founded 2 years ago
      
      MODERATORS
      
    you are viewing a single comment's thread
view the rest of the comments
    view the rest of the comments
 
          
          
True or false or null.
Mathematicians didn't know it yet, but numbers can now be even, odd or neither.
Ah, yes, a three-state boolean.
Even Linus Torvalds prefers an
int-based truthiness toboolNon integers certainly aren't even or odd, so yes?
Yeah, I'm chalking that up to Python's untypedness. I was going to write "integers", but technically that function takes a "num", whatever that is.
For all we know, it could be a string, asking ChatGPT to hack the government. Is that even? Probably no. Or None. Or T-Rex. Without reading the entire function, we don't know that it's not returning T-Rex.
Thankfully, it doesn't matter. Just stick the result into an if-else, then False and None will land you in the else-branch. And both True and our Truthiness-Rex will land you in the if-branch. Just as Guido intended.
...this rant brought to you by trauma.