Why and how "there is only one way to do something"?
Steve Holden
steve at holdenweb.com
Thu Dec 15 09:57:18 EST 2005
Ben Sizer wrote:
> Steve Holden wrote:
>
>
>>Would you, say, remove "for" loops because they could be written as
>>"while" loops. Don't forget the word "obvious" that appears in that
>>catchphrase ...
>
>
> Interestingly - and somewhat related to this - the other day I was
> looking for a do..while or do..until loop in the Python language
> reference, thinking that there must be a statement for it, since
> semantically they're distinct from while loops. I had a use case that
> could have been slightly simplified by such a construct. The fact that
> I didn't find one seemed slightly strange at first, coming from a
> C/Pascal background, although it did occur to me that I've used Python
> for years now and not noticed this lack before.
>
You'll find it's exercised the group frequently from time to time.
Without wishing to stir the whole thing up again, the essence of the
problem is the unnatural fit with Python's suite design.
Would you say
do:
suite
while condition
or what? Basically do ... while and do ... until most naturally put the
test after the loop body (suite), and it's difficult to think of a
consistent and natural syntax for expressing the construct. Not that
this stopped lots of people from coming forward with their personal
favourites ... some suggestions even offered "n and a half" looping
possibilities.
In the end nobody managed to convince Guido that a suitable solution was
readily to hand, so nothing happened.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
More information about the Python-list
mailing list