Matching Strings

John Machin sjmachin at lexicon.net
Fri Feb 9 20:19:09 EST 2007


On Feb 10, 11:58 am, Larry Bates <larry.ba... at websafe.com> wrote:
> rshepard-at-appl-ecosys.com wrote:
> > On 2007-02-10, rshep... at nospam.appl-ecosys.com wrote:
>
> >>       if item == selName:
>
> >   Slicing doesn't seem to do anything -- if I've done it correctly. I
> > changed the above to read,
>
> >    if item[2:-2] == selName:
>
> > but the output's the same.
>
> > Rich
>
> Use the interpreter to test things:
>
> a="(u'ground water',)"
>
> a[2:-2]
> "'ground water'"
>
> a[3:-3]
> 'ground water'
>
> That is what you are looking for.

True. Unfortunately he was looking for the wrong thing.
He has:
a = (u'ground water', )

a[2:-2] -> ()
a[3:-3] -> ()
() == 'ground water' -> False

HTH,
John




More information about the Python-list mailing list