scanf style parsing

Stefan Schwarzer s.schwarzer at ndh.net
Fri Sep 28 15:29:38 EDT 2001


Hi Tim

my posting is not really related to the scanf discussion but maybe helpful ...

Tim Hammerquist wrote:
> or, much more preferably:
> 
>     if filename[-4:] == '.txt':
>         ...

Since (I think:) Python 2.0 it's possible to use

if filename.endswith('.txt'):
    ...

which is less error-prone if the string is a bit longer.

Stefan



More information about the Python-list mailing list