> > 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
--
http://mail.python.org/mailman/listinfo/python-list