unsubscribe

Boulay,Patrick,PARIS Patrick.Boulay at fr.nestle.com
Fri Feb 25 03:32:00 EST 2000


unsubscribe

> -----Message d'origine-----
> De:	Fredrik Lundh [SMTP:effbot at telia.com]
> Date:	vendredi 25 février 2000 09:24
> À:	python-list at python.org
> Objet:	Re: system return status on Windows
> 
> Milos Prudek <prudek at nembv.cz> wrote:
> > Tim Peters wrote:
> > >
> > > [Milos Prudek
> > > You could also try os.spawnv or os.spawnve (but those only exist under
> > > Windows).  BTW, don't expect os.popen to work sensibly under Windows
> either.
> >
> > Great, thanks. Could you send something about mode (magic operational
> > constant) of spawnv? I do not have Visual C++ Runtime Library
> > documentation...
> 
> get the eff-bot guide ;-)
> 
> # os-spawn-example-3.py
> 
> import os
> import string
> 
> if os.name in ("nt", "dos"):
>     exefile = ".exe"
> else:
>     exefile = ""
> 
> def spawn(program, *args):
>     try:
>         # possible 1.6 shortcut!
>         return os.spawnvp(program, (program,) + args)
>     except AttributeError:
>         pass
>     try:
>         spawnv = os.spawnv
>     except AttributeError:
>         # assume it's unix
>         pid = os.fork()
>         if not pid:
>             os.execvp(program, (program,) + args)
>         return os.wait()[0]
>     else:
>         # got spawnv but no spawnp: go look for an executable
>         for path in string.split(os.environ["PATH"], os.pathsep):
>             file = os.path.join(path, program) + exefile
>             try:
>                 return spawnv(os.P_WAIT, file, (file,) + args)
>             except os.error:
>                 pass
>         raise IOError, "cannot find executable"
> 
> #
> # try it out!
> 
> spawn("python", "hello.py")
> 
> print "goodbye"
> 
> </F>
> 
> <!-- (the eff-bot guide to) the standard python library:
> http://www.pythonware.com/people/fredrik/librarybook.htm
> -->
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list