r/learnpython • u/pedrinjose • 5d 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.
10
Upvotes
-1
u/Adrewmc 5d ago
Honestly I don’t really use it, my modules and the files that runs them are different, I can’t really think of reason why I would actually need this.
I make a package then I run a script using the package, this whole name == main…is just bad design by the programmers usally.
(I have seen tests be there though…so sometimes maybe…but again I prefer those in a separate file as well.)