this post was submitted on 28 May 2025
721 points (96.3% liked)

Programmer Humor

23585 readers
2905 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
 

Also, do y'all call main() in the if block or do you just put the code you want to run in the if block?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 5 points 1 day ago* (last edited 1 day ago) (1 children)

wait till you see

if __name__ = "__main__":

   main()
`
[–] [email protected] 3 points 1 day ago* (last edited 1 day ago) (1 children)

Luckily Python is one step ahead:

Python 3.13.3 (main, Apr 22 2025, 00:00:00) [GCC 15.0.1 20250418 (Red Hat 15.0.1-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> if __name__ = "__main__":
... 
...    main()
...    
    File "<python-input-0>", line 1
    if __name__ = "__main__":
        ^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

Also TIL that := is a thing in Python.

[–] [email protected] 1 points 1 day ago* (last edited 1 day ago)

yea I also couldnt get the formatting to work right, triple quotes kept turning things into accented letters, so I gave up.

and also := also known as the walrus operator is very fun and sometimes very convenient to use