Nov-24-2023, 11:55 PM
i have a module that sometimes i want to run as a command. the problem is that the script that is importing it could be used as a command. thus, there are two scenarios in which variable __name__ would have the value "__main__". but. i want to be able to distinguish these two scenarios so that the module can stay being one file (perhaps named "foo.py") and be imported by a script (done simply like "import foo") where the importing script (perhaps named "bar.py") is run as a command. how can i make the module determine that it is invoked as a command without being confused by the importing script being invoked as a command.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.