[Python-3000] os.popen versus subprocess.Popen
Guido van Rossum
guido at python.org
Mon Apr 21 19:30:02 CEST 2008
IMO os.popen() is wrong here.
On Sat, Apr 12, 2008 at 4:33 PM, Tim Heaney <theaney at gmail.com> wrote:
> 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
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list