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

Programmer Humor

24828 readers
538 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] 26 points 1 month ago (11 children)

Python people explaining fail to see the point: Yes we know dunders exist. We just want you to say: "Yeah, that is a bit hacky, isn't it?"

[–] [email protected] 18 points 1 month ago* (last edited 1 month ago) (8 children)

Tbh reserving "main" is just a hacky if not more so than checking __name__ if you actually understand language design.

[–] [email protected] 2 points 1 month ago (1 children)

What is not hacky then in a language design?

[–] [email protected] 2 points 1 month ago (1 children)

Letting the developer decide what the code should do.

[–] [email protected] 1 points 1 month ago (1 children)

I don't understand. What do you mean by deciding what the code should do in the context of language design? Can you give a concrete example? I am confused because the "main" function is required when you make an executable. Otherwise, a library will not contain any main function and we could compile it just fine no? (Shared library)

[–] [email protected] 2 points 1 month ago

Python is an interpreted language that doesn't need a main function explicitly. You can define any package entry points you want at the package config level. (setup.py, etc)

example: What I meant was I prefer language that treat developers like adults. If I want ptrhon's "ux" to hide some functions or objects I can do that with underscores, but nothing is private, a developer using my library can do whatever they want with it, access whatever internals they want (at their own risk of course)

load more comments (6 replies)
load more comments (8 replies)