Author Baptiste.Lepilleur
Recipients Baptiste.Lepilleur, docs@python
Date 2013-02-24.12:20:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1361708455.88.0.426093416103.issue17286@psf.upfronthosting.co.za>
In-reply-to
Content
It tooks me a while to figure out that using universal_newlines was the solution to "tell" subprocess that I wanted text string output instead of byte string.

A search on stackoverflow shows that this issue is common and the solution nearly unknown (answer is usually to decode the byte string manually)...

Because dealing with text output is IMHO the most common use case, the subprocess documentation should make it easier to "find" the recipe.

I would suggest changing the documentation so that the universal_newlines is made obvious as it is very important:
1) the first /bin/vikings example be modified to show the use of this flag (at the top of the documentation, most people copy/past that):
  >>> p = subprocess.Popen(args, universal_newlines=True) # Success!
  and at a small comment below the example to explain that flag
2) change other example similarly when that make sense, IMHO:
   - ifconfig example
   - one of the subprocess.check_output example
   - subprocess.check_output() example, consider separating the byte string / text string example for increased visibility
3) consider adding a section with an obvious title "Dealing with binary and text input/output", providing examples and pointer to the correct documentation (I would place it after the convenience functions section for visibility). I think this would help attracting "eye" on this large piece of documentation.
History
Date User Action Args
2013-02-24 12:20:55Baptiste.Lepilleursetrecipients: + Baptiste.Lepilleur, docs@python
2013-02-24 12:20:55Baptiste.Lepilleursetmessageid: <1361708455.88.0.426093416103.issue17286@psf.upfronthosting.co.za>
2013-02-24 12:20:55Baptiste.Lepilleurlinkissue17286 messages
2013-02-24 12:20:55Baptiste.Lepilleurcreate