[Tutor] glob and file names

Gabriele Brambilla gb.gabrielebrambilla at gmail.com
Fri Jun 6 04:04:35 CEST 2014


Hi,

I'm trying to use glob to read a file of which I don't know the complete
name (but only some parts).


fiLUMOname = 'Lsum_' + period + '_' + parts[2] + '_' + parts[3] + '_' +
parts[4] + '_*.dat'

aaa = glob.glob(fiLUMOname)
print(aaa)
fiLUMO = open(aaa[0], 'r')


where period, and the elements of parts are strings.
but aaa results empty. (and so it cannot open the file)

The file exist and I'm able to recover it if I write by hand inside
glob.glob() the name between " " with the * where I don't know the name.

How can I pass my string to glob.glob inside " "?
Is there a simpler method to obtain the same result?

thanks

Gabriele
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140605/c1d73376/attachment.html>


More information about the Tutor mailing list