[Tutor] glob.glob(pattern, dir) ?

Sander Sweers sander.sweers at gmail.com
Tue Jun 9 17:40:26 CEST 2009


2009/6/9 spir <denis.spir at free.fr>:
> is there a way to make glob work in a specified dir?

glob needs a pathname and uses the current dir if no full path is
given. Prepend the path to your match (*.txt in example below) and it
works like you want it.

>>> import glob
>>> glob.glob('c:\\GTK\\*.txt')
['c:\\GTK\\license.txt']

Greets
Sander


More information about the Tutor mailing list