I have a python code (cmd.py
) which accepts files as command line arguments and process using parse_args. I want to pass files from another code (files.py
) to cmd.py
, just like passing function arguments.
Can this be done without modifying cmd.py?
Python – pipe function arguments to command line arguments in python
python
Best Answer
Yes it can be done:
Then first files.py is executed and the output (Example: "file1.txt file2.txt") is the input for the cmd.py.
Example:
This "cats" all the files found by ls in the working directory.