Re: scanf style parsing
by Aahz Maruch other posts by this author
Sep 30 2001 9:56PM messages near this date
Re: scanf style parsing
|
Re: scanf style parsing
In article <Xns91297E5A71028duncanrcpcouk@127.0.0.1> ,
Duncan Booth <duncan@[...].uk> wrote:
> tim@[...].cx (Tim Hammerquist) wrote in
> news:slrn9r61oo.uim.tim@vegeta.ath.cx:
>
> 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@pobox.com)
Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista
We must not let the evil of a few trample the freedoms of the many.
--
http://mail.python.org/mailman/listinfo/python-list
Thread:
Bruce Dawson
Skip Montanaro
George Demmy
Hans-Peter Jansen
Quinn Dunkan
Tim Hammerquist
Ralph Corderoy
Toby Dickenson
Duncan Booth
Aahz Maruch
Aahz Maruch
Aahz Maruch
Stefan Schwarzer
Grant Edwards
Fredrik Lundh
Malcolm Tredinnick
Ralph Corderoy
Tim Hammerquist
Stefan Schwarzer
Greg Ewing
Skip Montanaro
Boyd Roberts
Steve Clift
Bruce Dawson
Tim Hammerquist
Tim Hammerquist
Tim Hammerquist
Skip Montanaro
Andrew Dalke
Fredrik Lundh
Oleg Broytmann
Andrei Kulakov
Duncan Booth
Chris Barker
Tim Hammerquist
Skip Montanaro
Jon Nicoll
Oleg Broytmann
Bruce Dawson
Skip Montanaro
Andrei Kulakov
Richard Jones
Skip Montanaro
Andrew Dalke
|