[Tutor] try except continue
dyoo at hkn.eecs.berkeley.edu
Fri Jul 29 01:58:54 CEST 2005
> I see the continue statement as a way for me to do this, and thus
> intimately linked with exception handling.
I think you're getting too caught up with the word "continue" and its
concept as you use it in human language, rather than what it really does
in the Python language.
I should have written an example of 'continue' usage to make things more
explicit. Here is a simple example:
"""Filters empty lines out of standard input."""
for line in sys.stdin:
if not line.strip():
This is a small program that filters out empty lines from standard input.
The 'continue' statement causes us to immediately jump back to the
beginning of the loop and to keep going.
In Python, continue is intrinstically tied with Python's looping
It has very little to do with exception handling, except where the
footnotes mentions certain artificial limitations in using it within an
More information about the Tutor