[Python-3000] os.popen versus subprocess.Popen
Tim Heaney
theaney at gmail.com
Sun Apr 13 01:33:36 CEST 2008
In Python 3.0, it seems that os.popen yields a string, whereas
subprocess.Popen yields bytes
$ ./python
Python 3.0a4 (r30a4:62119, Apr 12 2008, 18:15:16)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, subprocess
>>> os.popen('date').readline()
'Sat Apr 12 19:08:05 EDT 2008\n'
>>> subprocess.Popen(['date'], stdout=subprocess.PIPE).communicate()[0]
b'Sat Apr 12 19:08:13 EDT 2008\n'
Is this intentional? If so, why should I expect this? Thanks!
Tim
More information about the Python-3000
mailing list