w chun wrote: > glob seems to be a good idea, but is there a way to do it > case-insensitively, i.e., .jpg and .JPG? > > it may be slower than glob, but i'm finding myself thinking more like... > > len([i for i in os.listdir('tmp') if i.lower().endswith('.jpg')]) > > now, anyone with a solution for .jpg, .JPG, .jpeg, *and* .JPEG?
glob.glob('*.[jJ][pP][eE]?[gG]') ?? or maybe (not sure this is legal; I'm pretty sure it's ugly :-) len([i for i in os.listdir('tmp') for suffix in ['.jpg', '.jpeg'] if i.lower().endswith(suffix)]) Kent > > -- wesley > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > "Core Python Programming", Prentice Hall, (c)2006,2001 > http://corepython.com > > wesley.j.chun :: wescpy-at-gmail.com <http://wescpy-at-gmail.com> > cyberweb.consulting : silicon valley, ca > http://cyberwebconsulting.com > > > ------------------------------------------------------------------------ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor