is their any limit on the size of the data passed to a program via popen2?

Jeff Shannon jeff at ccvcorp.com
Fri Feb 22 14:01:05 EST 2002


husam wrote:

>
>   pdbdir = os.popen('ls /home/data/pdbs') # if this directory contains
> 10000 files, the code does not work.
>
> files=pdbdir.readlines()
> pdbdir.close()

What you should do, in this case, is not use os.popen().  :)

Use os.listdir('/home/data/pdbs') instead.  It's faster, simpler, and much
more straightforward.  Or, if you need to limit filetypes even further, you
can use glob.glob().  Either of these is far preferable to using your
popen() call (which is almost equivalent to catching the subway, in order to
cross the street...)

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list