Python equivalent to @lines = 'command';

Tim Hammerquist tim at vegeta.ath.cx
Tue Dec 18 19:03:08 EST 2001


Christer Frovik <013-139047 at telia.com> graced us by uttering:
> Tim Hammerquist wrote:
> >     import os
> >     lines = os.popen('ls -1').readlines()
> >     for line in lines:
> >         process(line)
> 
> Thanks, you've made my day.
> 
> I wish those pyTHON (giggle) tutorials would include more of 
> these 'neat recepies'.

Glad to help.

If you're going to be doing a lot of text-processing, you might find
the shlex module interesting.

    http://www.python.org/doc/current/lib/module-shlex.html

HTH
Tim Hammerquist
-- 
$ echo pizza > /dev/oven



More information about the Python-list mailing list