control structures (was "Re: Sins")

Alexander Williams thantos at chancel.org
Sat Jan 8 18:18:14 EST 2000


On 8 Jan 2000 15:05:18 GMT, Aahz Maruch <aahz at netcom.com> wrote:

>>	for i in X: 
>>		if X[i]=e: goto Found
>>	print "Not Found"
>>	goto next
>>	Found: ...
>>	next
>>
>Why is using a flag or testing afterwards not acceptable?

Perhaps equally as important, why not use return to turn it into a
terminating event?

    >>> def searchX(lst, val):
    >>>     for e in X:
    >>>         if e == val: return 1  # Or perform some other block
    >>>                                #   of computation 
    >>>     return 0                   # Likewise

I suppose testing the resultant value of the func for results counts
as testing afterwards ... but I don't see any intuitive way of dealing
with the issue /without/ a test at some point.  In Skaller's original
code, the test occurs implicitly in the structure of the goto ... but
Python doesn't have arbitrary positional jumps like that (save for
Exceptions, which I feel have far better semantics, anyway).

Maybe I'm weird, but this feels like a "made up" issue.

-- 
Alexander Williams (thantos at gw.total-web.net)           | In the End,
  "Join the secret struggle for the soul of the world." | Oblivion
  Nobilis, a new Kind of RPG                            | Always
  http://www.chancel.org                                | Wins



More information about the Python-list mailing list