scanf style parsing

Toby Dickenson tdickenson at devmail.geminidataloggers.co.uk
Mon Oct 1 05:42:30 EDT 2001


"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.....



Toby Dickenson
tdickenson at geminidataloggers.com



More information about the Python-list mailing list