-1

I have a sample.bat file that has variable number of parameters. These parameters are coming from a python file:

# sample.py

p = Popen(['sample.bat', module_name_vista,
           memory_type_vista, linker_name_vista])

errors = p.communicate()
p.wait()

I want to know is there a way to pass variable number of arguments when invoking sample.bat file?

The number of parameters will vary depending on how user wants to use the batch file.

1

1 Answer 1

1

How about making the list dynamically and then passing it to Popen.

process_params_list = ['sample.bat']

for param in all_params:
  #condition for param to be added or not
  #or other processing on param
  process_params_list.append(param)

p = Popen(process_params_list)
Sign up to request clarification or add additional context in comments.

Comments

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.