Difference between Popen and open() for reading a file

Aahz aahz at pythoncraft.com
Fri Apr 30 17:17:40 EDT 2010


In article <mailman.2142.1271960906.23598.python-list at python.org>,
J  <dreadpiratejeff at gmail.com> wrote:
>
>Say I had a file, foo.txt that I wanted to read from, only one time
>and only read.
>
>So what's the difference between this:
>
>mylist = Popen(["cat","foo.txt"], stdout=PIPE).communicate()[0].splitlines()
>
>Is there a reason why you would not use subprocess.Popen for this,
>other than just not relying on external programs to perfrom the task?

http://uuoc.com/
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan



More information about the Python-list mailing list