#3481: request: else part for a for loop or make if to create variable
---------------------------------------+------------------------------------
   Reporter:  [EMAIL PROTECTED]  |                Owner:  adrian                
     Status:  new                      |            Component:  Template system 
      
    Version:  0.95                     |           Resolution:                  
      
   Keywords:  for if else loop         |                Stage:  Design decision 
needed
  Has_patch:  0                        |           Needs_docs:  0               
      
Needs_tests:  0                        |   Needs_better_patch:  0               
      
---------------------------------------+------------------------------------
Comment (by mtredinnick):

 It sounds like you are wanting "else" to only be executed when the "for"
 is not looped through. However, this is not the way it works in, for
 example, Python ("else" is executed when you don't break out of the loop
 prematurely). I don't think we want to implement it in a way that is so
 vastly different from Python: whilst we aren't implementing Python in
 templates, behaving completely the opposite way is going to be too
 confusing.
 
 Setting a variable is a slippery slope and not really in the spirit of
 templates. Fixing #2430 will help a little bit here (the if-test will be
 faster and memory efficient). Knowing that you are going to be accessing
 result_set.all() multiple times and passing it in as a !QuerySet to the
 template will help, too (that is the normal and recommended way to do this
 efficiently at the moment).
 
 There may be another solution available, so I'll leave this open in case
 another developer has an idea, but I am very much against using "else" in
 the proposed way; it's just too confusing for Python programmers.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/3481#comment:2>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to