[Zope] int's as keys for dictionaries

Bryce Harrington bryce at osdl.org
Tue May 25 21:28:07 EDT 2004


Nevermind, I figured it out.  "%d" % id

On Tue, 25 May 2004, Bryce Harrington wrote:

> I'm running into an issue I don't understand when using ints as keys in
> hashes.
>
>
> <dtml-let d_test_parameter="{'1':'a', '2':'b'}">
>
>   <p>We set id="1"</p>
>   <dtml-let id="1">
>     <p>This works:  <dtml-var "d_test_parameter.get('1')"></p>
>
>     <p>But this doesn't:  <dtml-var "d_test_parameter.get(id)"></p>
>
>     <p>Nor does this:  <dtml-var "d_test_parameter.get('id')"></p>
>
>   </dtml-let>
>
>   <p>Now set id="'1'"</p>
>   <dtml-let id="'1'">
>     <p>This works:  <dtml-var "d_test_parameter.get('1')"></p>
>
>     <p>Now this works:  <dtml-var "d_test_parameter.get(id)"></p>
>
>     <p>This still doesn't:  <dtml-var "d_test_parameter.get('id')"></p>
>
>   </dtml-let>
>
> </dtml-let>
>
> How can we force id to be interpreted as a string for the dictionary key
> in the first case?
>
> Thanks,
> Bryce
>
>
>
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>




More information about the Zope mailing list