[Zope] Simple Comparison - How to find the Template you are in in a list of all files in a directory

Passin,Thomas B. (Tom) tpassin@mitretek.org
Thu, 12 Sep 2002 15:50:52 -0400


[Edward Pollard]
>=20
> On Thursday, September 12, 2002, at 11:39 AM, Passin,Thomas B. (Tom)=20
> wrote:
>=20
> > [ Edward Pollard]
> >>
> >> Is this the incorrect way to compare strings? Is there a=20
> better way=20
> >> to do this?
> >>
> >
> > if a=3D=3Db: #do something
> >
>=20
> I tried this. It did not work. My thoughts are that =3D=3D would =
compare=20
> the pointers to the objects, not the contents.
>=20
It works for ordinary Python sequences and strings:

>>>a=3D'this is a test'
>>>b=3D''this is a test'
>>>a=3D=3Db
>>>1
>>>b=3D'xxx'
>>>a=3D=3Db
>>>0

For other object, it depends on how the comparison has been coded in the
class or type. =20


> Code wise, I have this
> <span tal:condition=3D"python:items.title_or_id =3D=3D=20
> template.title_or_id"=20
> tal:replace=3D"Content I want">Filler</span>
>=20
> items being the list I'm iterating through.
>=20
> So the obvious (=3D=3D) didn't work (apologies for not clarifying this =
in=20
> the first place), the next-obvious (cmp) didn't work, what will?
>=20

You may have to use the string value for the comparison.

Cheers,

Tom P