os.popen and place in file

Stephen Boulet stephen.boulet at motorola.com
Wed Jun 5 10:59:46 EDT 2002


I'm running windows NT.

The command: 

  f = os.popen('dir')

returns a file object 'f'. I can't however use the seek command on it:

for i in range(3):
   print f.readline()

f.seek(0) # Should put me back at the top of the "file"

for i in range(3):
   print f.readline()

This should (I think) print the same three lines again, but it doesn't.
Anyone know why?

-- Stephen

(By the way, f = os.popen('dir', 'rb') doesn't work either.)



More information about the Python-list mailing list