How do you conver output of "popen('ls')" to a list?
Wojtek Walczak
gminick at hacker.pl
Tue Mar 12 12:12:00 EST 2002
** Since micro$oft is stupid it doesn't mean
** that you should be stupid too - do NOT toppost.
Dnia Wed, 20 Feb 2002 10:54:13 +0100, husam napisał(a):
>thanks for reply.
---------
#!/usr/local/bin/python2.2
import os
blah = os.popen('ls').read()
i,n,tabl,blen=0,0,[],len(blah)
while i < blen:
tmp = i
i = blah.index('\n', i)
tabl.append(blah[tmp:i])
n+=1
i+=1
for a in tabl:
print a
---------
...just because readlines() forgot to cut '\n' ;))
--
[ Wojtek gminick Walczak ][ http://hacker.pl/gminick/ ]
[ gminick (at) hacker.pl ][ gminick (at) klub.chip.pl ]
More information about the Python-list
mailing list