I have a module which accepts arguments from the command line, let’s call that module A.
I would like to execute A from another module – B, so that B will set A‘s arguments-
without executing A as a separate process.
Any way to do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That depends on how module
Atakes it’s arguments. If it only looks atsys.argvand has no__main__test, then you could altersys.argv:then import module
A.However, if you are writing
Ayourself, use a function, called from a__main__test instead:then you can import
Aand callmain()directly:Note that if module
Ais not your own, and it does have a__main__test, but does all the work in thatif __name__ == '__main__':suite, then you are sunk and have to reproduce that code.