Passing arguments to a command line from a python script

Steven Bethard steven.bethard at gmail.com
Mon Mar 19 22:52:16 EDT 2007


Luis M. González wrote:
> On Mar 19, 10:49 pm, "zacherates" <zachera... at gmail.com> wrote:
>> This implies that `os.system("setuppy py2exe")` should do what you
>> want.
> 
> It works!
> Thank you, this is just what I wanted.

You'll get better error checking if instead you do::

     >>> import subprocess
     >>> subprocess.call(['setup.py', 'py2exe'])

Actually, you probably should really be doing::

     >>> subprocess.call(['python', 'setup.py', 'py2exe'])

so that you don't have to assume the OS knows how to run a .py file.

STeVe



More information about the Python-list mailing list