scanf style parsing
chasm at atlantis.rift
chasm at atlantis.rift
Sat Sep 29 11:47:49 EDT 2001
>> Regex's are useful and powerful. But they're also very easy to
>> abuse. I've actually seen the following Perl code:
>>
>> if ($filename =~ /\.txt$/) { ... }
>>
>> ...
>>
>> 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.
ext = '.txt'
if filename[-len(ext):] == ext:
etc...
Julian
More information about the Python-list
mailing list