New submission from Baptiste Lepilleur:

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.

----------
assignee: docs@python
components: Documentation
messages: 182872
nosy: Baptiste.Lepilleur, docs@python
priority: normal
severity: normal
status: open
title: Make subprocess handling text output with universal_newlines more obious
type: enhancement
versions: Python 3.1, Python 3.2, Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17286>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to