Re: I want to lirn pithon but pithon doesn't want me to do so
__name__ is the name of the current module (for example a.py, b.py, etc. without the py). It's not the file name, it's the name of the module that Python sees it as when you import it for the first time. How file is different from module is kind of esoteric and not important.
But when you run a script, the script isn't imported, it's the first file, and it needs a module name. So Python pretends it's __main__.
You can just not bother with that line, but the reason people do it is because documentation and other code analysis tools import all your modules, which runs the code in them. So if you run something like Sphinx and you don't have it, your game is going to start up instead of you getting docs. When something like Sphinx runs it's using __main__ because it started up first, and when it gets to your code it's not __main__ anymore (because it's a different module) and everything is fine.
You don't need to fully understand it, just use it. You'll probably never use __name__ for anything else ever, though __file__ (the path to the current file--not the name of the module, remember they're different) can be really useful for finding game resources and stuff, sometimes.
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector