The subprocess module is what you're looking for. Your example would look like
--------------------%<-------------------- import subprocess p = subprocess.Popen('cat hi.txt', shell=True, stdout=subprocess.PIPE) for line in p.stdout: print line --------------------%<-------------------- I assume you know that you can just open a file for reading instead of piping cat. thomas James Hartley wrote: > 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. > > Jim > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor