1

I have the following folder and files:

script_folder
|__   __main__.py
|__   script1.py
|__   script2.py

The file __main__.py allows running the folder as a script, so I can do something like: python3 script_folder. Also, script1.py and script.py are scripts each having different command line arguments. My goal is to be able to run the folder script as such:

    python3 script_folder script1 --normalize -o output.txt

where the positional argument (script1) tells folder_script to run script1.py and the options --noramlize and -o are options specific for script1.py. What is the best way to run the correct script and pass along the command line arguments to the correct file script from __main__.py folder script?

Note: I am using argparse to parse the arguments in each file script.

1 Answer 1

2

Don't. Call the script directly (after making script_folder a package, if required).

python3 -m script_folder.script1 --normalize -o output.txt
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, just what I needed, I knew there is something I am missing! Much easier than I thought it would be.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.