[Zope] Re: [Zope-dev] Stupid dtml-if comparision

J Cameron Cooper jccooper@jcameroncooper.com
Thu, 06 Mar 2003 17:47:29 -0600

>I'm trying to compare two number, or at least I think they're numbers.
>If I do:
>   <dtml-var i>
>   <dtml-var j>
>   <dtml-if expr="i == j">
>     Equal block
>   </dtml-if>
>I and J print out the same, but do not compare to be equal since "Equal
>block" string doesn't print.
Whenever I try this when they're the same type it works.

It they're not the same type it'll never work. Unfortunately the type() 
built-in isn't available in DTML or Python scripts (if you go to an 
ExternalMethod you should be able to use it.)

What you can try is this:

str(i)==str(j) to compare the string representations

or, if you're dealing with a certain type of number,


In DTML, you have to call these from the namespace '_' (underscore) as so: