Python equivalent to @lines = 'command';

Christer Frovik 013-139047 at telia.com
Tue Dec 18 09:09:36 EST 2001


Is is possible to spawn a command (any command not just ls) 
and have all the lines that the command outputs stored in a list?

In PERL this is done quite nicely in a single statement:

  @files = `ls -1`;

and you can then iterate over @files and do whatever you want.
Any ideas, or should i stick with Perl for my mindless scripts?



More information about the Python-list mailing list