I would like to keep the same name of my script, but have one for automatic execution (which would not take any parameters), and one for ad hoc execution (which would take parameters). Would something like the code below work?
#myPythonFile.py
import sys
def main():
if argv[1] is None:
#Do something
elif:
#Do something else
if __name__ == '__main__':
main()
Then I could either call
myPythonFile.py
or
myPythonFile.py 'param1', 'param2'
correct?
Here is how you can check arguments passed:
Here is how it would work
If you use optparse or argeparse however:
Here is how it would look