subprocess - please enhance the documentation

H

Helmut Jarausch

Hi,

I'd like to suggest to add a few lines to chapter 17.1.3.5 "Replacing os.popen"
(Python Doc 2.5.2)

I have used the following code in the past

ARC='MyDumpFile'
tar_inp= os.popen('/bin/tar cjf '+ARC+' -T -','w')
.....
tar_exit_code= tar_inp.close()
if tar_exit_code != None and tar_exit_code % 256 :
print "some error messages"

When replacing this - as suggested - by

TAR= Popen(('/bin/tar','cjf',ARC,'-T','-'),stdin=PIPE)
tar_inp= TAR.stdin
.....
tar_inp.close() always returns None.

So I have replaced this by

tar_inp.close()
tar_exit_code= TAR.wait()

if tar_exit_code != 0 :
print "some error messages"


Perhaps a few lines telling about this would be helpful.

Thanks,
Helmut.

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
 
T

Terry Reedy

| Hi,
|
| I'd like to suggest to add a few lines to chapter 17.1.3.5 "Replacing
os.popen"
| (Python Doc 2.5.2)

1. Take a look at the existing 2.6 manual (on Python.org) to make sure it
has not already been improved. If not..

2. Post your suggestions on bugs.python.org and mark the item as
documentation and stdlib. Suggest the specific addition or change you
would like to see. If accepted, one of the doc-masters with add it with
the needed formatting code and possibly stylistic changes.

| I have used the following code in the past
|
| ARC='MyDumpFile'
| tar_inp= os.popen('/bin/tar cjf '+ARC+' -T -','w')
| ....
| tar_exit_code= tar_inp.close()
| if tar_exit_code != None and tar_exit_code % 256 :
| print "some error messages"
|
| When replacing this - as suggested - by
|
| TAR= Popen(('/bin/tar','cjf',ARC,'-T','-'),stdin=PIPE)
| tar_inp= TAR.stdin
| ....
| tar_inp.close() always returns None.
|
| So I have replaced this by
|
| tar_inp.close()
| tar_exit_code= TAR.wait()
|
| if tar_exit_code != 0 :
| print "some error messages"
|
|
| Perhaps a few lines telling about this would be helpful.
|
| Thanks,
| Helmut.
|
| --
| Helmut Jarausch
|
| Lehrstuhl fuer Numerische Mathematik
| RWTH - Aachen University
| D 52056 Aachen, Germany
| --
| http://mail.python.org/mailman/listinfo/python-list
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top