1.5.2 for: else:
John Max Skaller
skaller at maxtal.com.au
Wed Aug 4 02:36:50 EDT 1999
On Wed, 28 Jul 1999 14:57:55 -0700, "Vadim Chugunov" <chega_ at yahoo.com> wrote:
>When I first saw Python syntax for loops I said: "A-ha! So in Python I will not
>need a goto
>in situations like this:
>-----
>for(Item* pitem=pseq->First(); pitem; pitem=pitem->Next())
> if (pitem->key==42)
> goto Found;
>
>pitem = pseq->Insert(new Item());
>Found:
> // use item pointed to by pitem
>-----
>In fact, I do not see any other good use for else: clause in a loop.
Isn't this a fine reason for it?
John Max Skaller ph:61-2-96600850
mailto:skaller at maxtal.com.au 10/1 Toxteth Rd
http://www.maxtal.com.au/~skaller Glebe 2037 NSW AUSTRALIA
More information about the Python-list
mailing list