I need to retract this. os.popen() has a 'mode' flag that indicates
reading or writing but also specifies text vs. binary. So
os.popen(..., 'r') should return a text stream, while os.popen(...,
'rb') should return a binary stream.

The subprocess module has similar options, though the default is
geared more towards binary.

I still think os.popen() should be reimplemented on top of subprocess,
and add the same optional flags as the open() function has grown to
indicate encoding and buffering.

I think the more complex variants (popen2, popen3, popen4, ...?)
should probably go away, since it's easy enough to do what they do
using the subprocess module, and there were some serious API design
mistakes there (confusing reversal of input and output in some cases).

--Guido

On Mon, Apr 21, 2008 at 10:30 AM, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> IMO os.popen() is wrong here.
>
>
>
>  On Sat, Apr 12, 2008 at 4:33 PM, Tim Heaney <[EMAIL PROTECTED]> 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@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/)
>



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to