ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Re: scanf style parsing
by Tim Hammerquist other posts by this author
Sep 28 2001 9:59PM messages near this date
Re: scanf style parsing | Re: scanf style parsing
Me parece que Stefan Schwarzer <s.schwarzer@[...].net>  dijo:
>  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.

..and much more maintainable. You no longer must change the index when
the length of the string changes.  Very nice.  I hadn't been
familiarized with this method.  Thank you for bringing it up.

>  Stefan

Tim Hammerquist
-- 
I would feel infinitely more comfortable in your presence if you would agree
to treat Gravity as a Law, rather than one of a number suggested options.
    -- Barnabas, The Sandman
-- 
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved