os.listdir

Chris Barker chrishbarker at home.net
Tue Oct 30 15:38:00 EST 2001


Randy Heiland wrote:
> I get this:
> 
> >>> for file in os.listdir('mydir'):
> ...   print file
> ...
> f100.dat
> f1.dat
> f2.dat
> 
> but would like this:
> f1.dat
> f2.dat
> f100.dat

I use file names like:
f001.dat
f002.dat
f100.dat

Just to avoid this issue. It is not a Python issue at all. However, if
you don't have control over the file names, others have offered good
suggestions...

-Chris


-- 
Christopher Barker,
Ph.D.                                                           
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------



More information about the Python-list mailing list