scanf style parsing

Aahz Maruch aahz at
Sun Sep 30 23:56:26 CEST 2001

In article <Xns91297E5A71028duncanrcpcouk at>,
Duncan Booth  <duncan at> wrote:
>tim at (Tim Hammerquist) wrote in 
>news:slrn9r61oo.uim.tim at
>Wouldn't you be happier with this?:
>   extensions = ['.htm', '.html', '.shtm', '.shtml', '.phtm',
>        '.phtml', '.cgi', '.php', '.php2', 'php3', '.php4', '.pl']
>   ext = os.path.splitext(filename)[1]
>   if ext in extensions:
>      ...
>which has the arguable advantage of matching what your description says 
>instead of what your original code does.

Well, if you're going to do that, extensions should be a dict for real
speed.  ;-)

>regexes are wonderful: in moderation.

'Some people, when confronted with a problem, think "I know, I'll use regular
expressions".  Now they have two problems.'  --Jamie Zawinski, comp.lang.emacs
                      --- Aahz  <*>  (Copyright 2001 by aahz at

Hugs and backrubs -- I break Rule 6       
Androgynous poly kinky vanilla queer het Pythonista   

We must not let the evil of a few trample the freedoms of the many.

More information about the Python-list mailing list