The else clause executes unless a loop is broken (that is, with the break or obviously by raising an exception), and executes after a loop ends normally.
>>> for i in "abc":... pass ... else: ... print "else" else >>> On Wed, Oct 29, 2008 at 8:32 PM, Ned Batchelder <[EMAIL PROTECTED]>wrote: > But this does operate the same as the Python for/else, no? > > >>> for i in []: > ... print "boo" > ... else: > ... print "foo" > ... > foo > >>> > > --Ned. > http://nedbatchelder.com > > > Calvin Spealman wrote: > > On Tue, Oct 28, 2008 at 8:18 PM, oggie rob <[EMAIL PROTECTED]> wrote: > >> >> > {% for item in grocery_list %} >> > {{ item }} >> > {% default %} >> > Nothing to buy. >> > {% endfor %} >> > >> Please, though - use {% else %}. Its totally clear what its referring >> to and else doesn't mean squat unless you see what the if (and in this >> case, for) test is anyway, so I don't think this would be confusing >> (after all, this isn't python). >> (Also, if you want to avoid confusion don't use a keyword that is >> located within another language's looping construct :) >> > > Please dont use else, because {%for%} matches python's for loop and that > supports an else clause which does not operate like this. If the same > keyword is used, it should behave the same. > > > -- > Read my blog! I depend on your acceptance of my opinion! I am interesting! > http://techblog.ironfroggy.com/ > Follow me if you're into that sort of thing: > http://www.twitter.com/ironfroggy > > > > -- > Ned Batchelder, http://nedbatchelder.com > > > > > -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://techblog.ironfroggy.com/ Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---