fnmatch() function

Psybar Phreak psybar_phreak at yahoo.com
Fri May 16 20:49:35 EDT 2003


also - i figure i have 2 ways in which this can be done

1) filter the contents of the directory, or
2) loop through every file in the firectoy, and check the filename before
printing its contents

help with either option wold be grealty appreciated!



"Psybar Phreak" <psybar_phreak at yahoo.com> wrote in message
news:3ec580e6$0$15841$afc38c87 at news.optusnet.com.au...
> hi everyone
>
> here's my situation - i have a sub-folder (called diaries) i have some
files
> and sub-folders within that folder.  the files ahve different extensions
> (*.dia, *.eve).
>
> what i want to do it go through all the files in the folder that end in
> *.dia, and print the first 2 lines from them.
>
> now ive just found the function called fnmatch() (after trying to use glob
> only to realise its for PATHname and not FILEnames)
>
> would this be the best thing to use?  can someone show me how this would
be
> done, cause i really can't find anything about how to actually USE the
> function
>
> thanks everyone!
>
>






More information about the Python-list mailing list