> From: James Hartley <> > Subject: [Tutor] opening a pipe? > Sent: 2008-02-12 09:24 > > A Perl script can easily serve as a filter within a pipe as seen in > the following: > > use strict; > use warnings; > > open(IN, 'cat hello.txt |') or die 'unable to open file'; > while (<IN>) { > print; > } > close(IN); > > Can I do the same within Python? Thanks. >
os.popen can do this. The 'commands' module provides even more flexibility. If you are on a posix platform and want to avoid shell interpretation, you could also try my pipeline package at http://pypi.python.org/pypi/pipeline.py/0.1 -- Yorick "Our servers are using too much electricity. We need to virtualize." _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor