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
- 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
Python has a bunch of magic variables, like
__name__
. This one contains the name of the module you're currently in (usually based on the file name), so if your file is calledfoo.py
, it will have the valuefoo
.But that's only if your module is being imported by another module. If it's executed directly (e.g.
python foo.py
), it will instead have a__name__
of__main__
. This is often used to add a standalone CLI section to modules - e.g. the module usually only defines functions that can be imported, but when executed it runs an example of those functions.checks username
So it's you they're always talking about
It is, it's the other Barry.
Really helpful explanation, thanks.