exceptions == errors?
Skip Montanaro
skip at pobox.com
Mon Apr 7 20:20:45 EDT 2003
Mark> Are exceptions always considered errors, or there the same feeling
Mark> as in C++ that exceptions can be used for non-error situations?
Exceptions are frequently used to signal non-error conditions. For example,
they can be used to break out of nested loops:
class Finished(exception): pass
try:
for foo in some_list:
for bar in some_other_list:
...
if conditions_met:
raise Finished
...
except Finished:
pass
Skip
More information about the Python-list
mailing list