scanf style parsing
Tim Hammerquist
tim at vegeta.ath.cx
Mon Oct 1 16:04:30 EDT 2001
Me parece que Toby Dickenson <tdickenson at devmail.geminidataloggers.co.uk> dijo:
> "Fredrik Lundh" <fredrik at pythonware.com> wrote:
>
> >Ralph Corderoy wrote:
> >> > or, much more preferably:
> >> >
> >> > if filename[-4:] == '.txt':
> >>
> >> Overall, the Perl code's better. It didn't have to hard-code the
> >> length of the string.
> >
> >if it matters, use endswith instead:
> >
> > if filename.endswith('.txt'):
> > ...
>
> That wont match any .TXT files. Whether thats a problem depends on
> whether you use Windows or not.....
Wouldn't be the first time Windows was a thorn in my side. But:
filename = 'AUTOEXEC.BAT'
if filename.lower().endswith('.bat'):
# things and stuff
> Toby Dickenson
> tdickenson at geminidataloggers.com
Tim Hammerquist
--
"Supported" is an MS term that means the function exists. The fact
that it always fails means that it is an exercise for the programmer.
-- Sarathy, p5p
More information about the Python-list
mailing list