” when we see them for the first time. These are the variables and functions that come preloaded in our favorite language, like a gift from the programming gods themselves. But let’s be real here, they can also be pretty confusing if you don’t know what they do or why they exist.
First up, we have `__name__`. This is one of those names that makes us wonder if Python has a secret agenda to mess with our minds. What does it mean? Well, let me explain in the most casual way possible: when you run your Python script (or module), this variable tells you whether or not it’s being executed as a standalone program or imported into another file. If it’s running on its own, `__name__` will be set to “main”. But if it’s being imported by someone else, it’ll have the name of that module instead (like “my_module”).
Now let’s move onto some other system-defined names that are a bit more useful. We have `__builtins__`, which is basically a dictionary containing all the built-in functions and modules in Python. This can be really handy if you want to check what’s available without having to look it up every time (although, let’s face it we all do that anyway).
Another one worth mentioning is `__doc__`, which holds a string containing the docstring for your module or function. This can be really helpful if you want to see what something does before using it, especially when working with third-party libraries (because let’s face it we all hate reading documentation).
Finally, there’s `__package__`, which tells us the name of the package that our module belongs to. This can be useful if you have a bunch of modules in your project and want to keep them organized by package.
Remember when in doubt, consult the documentation or ask a friend who knows more than you do about this stuff.