python "jump" or "goto" commands?
Courageous
jkraska1 at san.rr.com
Thu May 31 20:39:45 EDT 2001
>> try:
>> for i in range(100):
>> for j in range(100):
>> if i*j > 2500:
>> raise Label
>> except Label:
>> pass
>>
>
>Or a function with a return statement.. that personally feels a cleaner to me.
This works poorly in the event that several exit points require cleanup of
some kind. In C, I often favor constructs of the form:
if (bad) goto bail;
bail:
cleanup();
Log(logger, "something bad happened\n");
return 0;
Where numerous conditions can move you to the bail-out point. This
is, of course, trumped by an exception in Python.
C//
More information about the Python-list
mailing list