In my template, I have:
<p py:for="" time in datasets, times">
<div py:content="form.display(dataset)">form</div>
Total Time: ${time}
</p>
When I run it, it complains that there are either too many values to
unpack or not enough, depending upon how many dataset items there are
in datasets.
Using the comma after the in keyword creates a tuple of two elements. So the for loop is actually looping over two things (a dict and a list). For example:
>>> d = [{}, {}, {}]
>>> t = [0, 0, 0]
>>> for x, y in d, t:
... print x, y
...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: unpack list of wrong size
>>> for x in d, t:
... print x
...
[{}, {}, {}]
[0, 0, 0]
>>>
What you can do instead is something like:
py:for="" time in datasets, times" # untested but should work
or you can always loop through range(len(datasets)) and access everything by index.
David
http://www.traceback.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

