[Tutor] Slicing Question
Francois Granger
francois.granger@free.fr
Wed Apr 9 13:37:30 2003
At 12:46 -0400 09/04/2003, in message [Tutor] Slicing Question, Brian
Christopher Robinson wrote:
>I wrote this line of code today:
>
>if fileName[:-5][-4:].lower() == "test":
>
>What it does it take a file name that I already know ends in
>".java", cut off the ".java" part, and see if the last 4 letters are
>test. I was wondering if there's a simpler way of doing this?
if filename.lower().find('test.java') > -1:
or using split. It depend on what else you do to the filename.
--
Hofstadter's Law :
It always takes longer than you expect, even when you take into
account Hofstadter's Law.