[Tutor] Fwd: glob and file names

Gabriele Brambilla gb.gabrielebrambilla at gmail.com
Fri Jun 6 20:16:11 CEST 2014


oh yes! I had a problem inside the file name! (I had a lot of file to open
and I changed the one I was looking at!the one I was trying to open has a
wrong filename...)

Sorry for the misunderstanding.

Gabriele


2014-06-06 3:05 GMT-04:00 Peter Otten <__peter__ at web.de>:

> 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[2] + '_' + parts[3] + '_'
> >>> + parts[4] + '_*.dat'
> >>>
> >>> aaa = glob.glob(fiLUMOname)
> >>> print(aaa)
> >>> fiLUMO = open(aaa[0], 'r')
> >>
> >> i would do:
> >>
> >> aaa = glob.glob('Lsum_%s_%s_%s_%s_*.dat' % (period, parts[2], parts[3],
> >> parts[4]))
> >
> > 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?
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140606/97b1ff9e/attachment.html>


More information about the Tutor mailing list