this post was submitted on 28 May 2025
711 points (96.2% liked)

Programmer Humor

23609 readers
1565 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
[โ€“] grrgyle@slrpnk.net 3 points 5 days ago (1 children)

I'm not sure I'm following the implication. Name=main is for scripts primary, is it not?

I've never thought to add more than one of these conditionals anyway...

[โ€“] bane_killgrind@slrpnk.net 2 points 4 days ago

So you might have a script that does stuff as a library, and it should get environment variables and other info from the calling script. You use the same script for doing one off stuff on different computers.

So you make it do something slightly different or make it set it's path and look into the current folder when you run it directly. This change in logic could be in a few points in the script.