[Tutor] Fwd: glob and file names
__peter__ at web.de
Fri Jun 6 09:05:44 CEST 2014
Gabriele Brambilla wrote:
> 2014-06-05 22:10 GMT-04:00 Peter Romfeld <peter.romfeld.hk at gmail.com>:
> On Friday, June 06, 2014 10:04 AM, Gabriele Brambilla wrote:
>>> fiLUMOname = 'Lsum_' + period + '_' + parts + '_' + parts + '_'
>>> + parts + '_*.dat'
>>> aaa = glob.glob(fiLUMOname)
>>> fiLUMO = open(aaa, 'r')
>> i would do:
>> aaa = glob.glob('Lsum_%s_%s_%s_%s_*.dat' % (period, parts, parts,
> thanks, it works.
While Peter's way may be easier to read both approaches should give you the
same result, assuming 'period' and the items in the 'parts' list are all
strings. There must be an accidental change elsewhere -- maybe you changed
the current working directory before invoking the script?
More information about the Tutor