Control of flow

Campbell cb921 at
Tue Jul 31 13:24:49 EDT 2001

On Tue, 31 Jul 2001, Alex Martelli wrote:

>"Campbell" <cb921 at> wrote in message
>news:Pine.LNX.4.31.0107311355450.2321-100000 at cb921.local...
>> I use python to write telephony apps, and I find that a 'goto' is often
>> a nice tool (stop going 'aargh', its properly "useful" sometimes =).
>Naah, you can always get the same effect with better structure:-).

So I have been told. :)

>What are the conditions under which you want to repeat
>this inner loop (letting the user enter a day for the
>fixed month) rather than redo the outer loop (letting
>the user enter the month again)?

In this case I'd like to keep the caller in the inner (day) loop,
entering '#' cound be checked to go to the outer loop, but I use
constructs like this for many things.  Sometimes a caller will enter the
begin and end of a range, and which loop to jump into could depend on
what specific error condition was noticed.  I've made something exactly
this ugly (except which worked) twice today already, and this is what it
all gets to look like?  Every time I do it, I think to myself, that it
is rare unless I'm handling this kind of input, where values are
available one at a time, and I must respond with prompts correctly.
Following which is the thought: "that sort of input is kind of
common around this place..."

Here is where Perl's name-able loops are remembered with fondness.
(but Perl by nature just isn't maintainable of course ;-)

>that's not too bad for a couple of entries, but it
>gets slightly tiresome when you have a zillion.  That
>is (part of:-) what exceptions are for...

thank you... I could make an interesting while 1: with a try: inside of
it handling custom exceptions, and in each except: could have the
retry/continue stuff.  Still, for the common situation where context
differs and 'error' conditions that are checked for vary, it seems like
a bit of overkill.  It's not that I mind doing it, it's at least
'elegant' while my cont variables are not, I just mind having to explain
that to the workers :)

I'm trying to replace a commercial telephony platform with something I
hacked together with swig and Py, on which many different applications
share the server, each with it's own number.  So far it's going very
well, the only Gripe I have ever heard from others (or had myself)  has
been this.  So I shouldn't whine too loud, Python really has changed my
world for the better. :)

Alex Thanks, I sincerely appreciate your thought and time.

    The world is our spoon
     tick, tock.

More information about the Python-list mailing list