any sane language has == behave that way. Javascript == is just completely bonkers.
- 0 Posts
- 3 Comments
Joined 2 years ago
Cake day: April 21st, 2024
You are not logged in. If you use a Fediverse account that is able to follow users, you can follow this user.
I mean yeah with no context that looks weird A/F, but given a couple details it’s fairly self-evident why it be like it do.
- Python doesn’t need a main function. It’ll just start running any top level code. This is nice for beginners learning programming because there’s no scaffolding or anything to set up. It just do the thing.
- python uses double underscores (usually called “dunder”) to mark “special” things.
__name__is a global variable containing the name of the current module. There’s a couple more like__file__containing the filename of the current module. - If you run a file directly
__name__gets set to"__main__". If it got set to something more sensible like"main"you couldn’t really call a filemain.pywithout this breaking. Right now this only breaks for files called__main__.pybut luck would have it that calling a file__main__.pyalready has a special meaning which makes these uses not clash. - Sometimes you want code to only run if a module is run but not when it is imported. Checking if
__name__is set to__main__is the easiest way to do this.
Python for sure has a bunch of weirdness, but it all does mesh together into a rather nice programming language.


That last bit is absurd. A mountain was over highway speeds for 30 minutes?
Crazy