r/learnpython • u/pedrinjose • 8m ago
Basically, if main
In Python, when you run your program in another folder, we add this, but I don't understand why. What's the point of doing this? If someone could explain it in a simplified way, I'd appreciate it.
1
Upvotes
•
u/This_Growth2898 1m ago
Because you can import your file as a library and in that case you don't want it to run, just to import some functions.
ensures the file is called directly, not imported.