Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43703

Re: Calling python script in dos and passing arguments

Date 2013-04-16 13:25 -0600
From Michael Torrie <torriem@gmail.com>
Subject Re: Calling python script in dos and passing arguments
References <88b87ac0-1fce-4383-9841-d99a49f50556@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.689.1366140333.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 04/16/2013 08:14 AM, PEnergy wrote:
> Greetings,
> 
> I am trying to write a python script that, when called from the DOS
> prompt, will call another python script and pass it input variables.
> My current code will open the other python script but doesn't seem to
> pass it any values:
> 
> import os,sys,subprocess 
> subprocess.Popen(['python.exe','C:\NDEX\GRE2\uip\uip_20.py','t3c*'])

I find it easier just to write my python programs such that they can be
imported into other python scripts.  Usually I use this form:

def func(*whatever):
    pass

if __name__ == "__main__":
  # parse command-line arguments
  # call functions in this module with those args
  func(1,2,3,etc)

This way a script can be run standalone, or I can import it and access
its attributes direction.  I recommend you consider this approach.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Calling python script in dos and passing arguments PEnergy <prquinn@gmail.com> - 2013-04-16 07:14 -0700
  Re: Calling python script in dos and passing arguments Chris Rebert <clp2@rebertia.com> - 2013-04-16 12:10 -0700
    Re: Calling python script in dos and passing arguments Alister <alister.ware@ntlworld.com> - 2013-04-16 19:19 +0000
    Re: Calling python script in dos and passing arguments Tim Roberts <timr@probo.com> - 2013-04-16 22:32 -0700
  Re: Calling python script in dos and passing arguments Michael Torrie <torriem@gmail.com> - 2013-04-16 13:25 -0600

csiph-web