Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

python's for/else doesn't do what the grandparent post asked for -- that post asked for the else clause to execute if the container that was being iterated over is empty, and in python's for/else (as your link notes) the else clause executes whenever the for clause terminates normally (that is, other than by a break statement). These are very different constructs.


So it does. I wonder what language I was thinking of then.


This is a long shot, but could you be thinking of the Django template language?

https://docs.djangoproject.com/en/dev/ref/templates/builtins...

    <ul>
    {% for athlete in athlete_list %}
        <li>{{ athlete.name }}</li>
    {% empty %}
        <li>Sorry, no athletes in this list.</li>
    {% endfor %}
    </ul>




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: