parsing directory for certain filetypes

Robert Bossy Robert.Bossy at jouy.inra.fr
Mon Mar 10 16:04:26 CET 2008


jay graves wrote:
> On Mar 10, 9:28 am, Robert Bossy <Robert.Bo... at jouy.inra.fr> wrote:
>   
>> Personally, I'd use glob.glob:
>>
>> import os.path
>> import glob
>>
>> def parsefolder(folder):
>>     path = os.path.normpath(os.path.join(folder, '*.py'))
>>     lst = [ fn for fn in glob.glob(path) ]
>>     lst.sort()
>>     return lst
>>
>>     
>
> Why the 'no-op' list comprehension?  Typo?
>   
My mistake, it is:

import os.path
import glob

def parsefolder(folder):
    path = os.path.normpath(os.path.join(folder, '*.py'))
    lst = glob.glob(path)
    lst.sort()
    return lst





More information about the Python-list mailing list