[Tutor] glob in order of the file numbers

Senthil Kumaran orsenthil at gmail.com
Sat Mar 7 04:15:54 CET 2009


2009/3/7 Emad Nawfal (عماد نوفل) <emadnawfal at gmail.com>:
> import glob
> for path in glob.iglob("*.temp"):
>     infile = open(path)
>     for line in infile:
>         print line.strip()

import glob
files = sorted(glob.glob("*.temp"))
for each in files:
    print open(each).read()


Note couple of things:
- glob.glob
- sorted to arranged in order.
- just read() the fhandle to read the contents.

-- 
Senthil


More information about the Tutor mailing list