mettwoch@pt.lu wrote:
Hi,
Could someone explain why iterating over a list of lists, like this:
<dtml-in expr="[[1,1],[2,2]]"> <dtml-var sequence-item><br> </dtml-in>
gives as result: [1,1] [2,2]
but iterating over a list of tuples like this:
<dtml-in expr="[(1,3),(2,4)]"> <dtml-var sequence-item><br> </dtml-in>
gives as result 3 4
A list of tuples is created for instance when applying the items() method on a dictionary resulting from a SQL method call.
When doing the above iterations in Python console, it gives the expected result eg. two lists and two tuples.
DTML breaks that up in sequence-item and sequence-key. From Zope online help for dtml-in: """ Tag Variables Current Item Variables These variables describe the current item. sequence-item The current item. sequence-key The current key. When looping over tuples of the form (key,value), the in tag interprets them as (sequence-key, sequence-item). """ I can't really say why, though. --jcc