A single, general looping construct? (was: why no "do : until"?)

Pawel Kedzierski kedziers at pkmk486.ch.pwr.wroc.pl
Tue Jan 9 07:04:17 EST 2001


Hi there,

  I become a python enthusiast a short time ago and even I adopted it
as a programming language for my classes on programming in chemistry.
It allowed to shift the balance of training/applications largery to
the right side :-); However, I also found hard to explain why there
isn't any repeat ... until replacement in Python.

  So it is why I am here :-). The actual hot discussion i have read
on this thread and before indicates that although the topic was discussed
thorough the whole Python lifetime. So I'm not going to add any more
pros as there were so many mentioned. I simply come with an idea,
which seems attractive, so let's have it discussed.

  As far as I understand, the main reason against another loop construct
is the need to introduce a new keyword. Here is a solution, which doesn't
need it. And, IMHO, it is simple, elegant yet powerful:

Let's extend the meaning of try and while.

The try: statement could begin both the exception control and the loop.
Of course, in this case either the except clause or the while one would
be optional.
I would especially like constructs like this:

try:
  f = raw_input('Data file: ')
  f = open(f,'r')
except IOError:
  print 'Could not open file'
while not IOError

What do You all think about it?

Best regards

        Pawel

-- 
--> email: P.Kedzierski at mml.ch.pwr.wroc.pl
    Molecular Modelling Laboratory
    Institute of Physical and Theoretical Chemistry I-30
    Wroclaw University of Technology
    Wroclaw, POLAND




More information about the Python-list mailing list