scanf style parsing

Fredrik Lundh fredrik at pythonware.com
Sat Sep 29 12:05:55 EDT 2001


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'):
        ...

</F>





More information about the Python-list mailing list