On Wed, 2009-03-11 at 02:25 -0700, johan.u...@student.hpi.uni-potsdam.de
wrote:
> Thanks a lot. I was just blind eyed yesterday I think. Corrected code
> is:
> 
> {% for key,value in dictionary.items %}
>         <h2>{{key|date:"Y-m-d"}}</h2>
>         {% for key,value in value.items %}
>                 <h3>{{ key.0|date:"H.i" }} - {{ key.1|date:"H.i" }}</
> h3>

Speaking as somebody who regularly maintains code written two to three
years earlier in a number of projects, I would seriously think of not
reusing "key" and "value" in both loops. As things get more complicated,
and particularly if you use that as a general pattern in your work, you
will go cross-eyed trying to work out if there are scoping (or
accidental variable hiding) problems.

Basically, try to write code so that something that looks wrong *is*
wrong. In this, it looks potentially wrong, but turns out to work. That
kind of slight brain speed-bump won't help you spot real errors quickly
in the future.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to