"do" as a keyword

Diez B. Roggisch deets at nospam.web.de
Tue Dec 11 09:48:25 EST 2007


cokofreedom at gmail.com wrote:

> First off let me state that I really enjoy using Python. I am a 3rd
> year student and have been using python for 3 months, (thanks to
> trac!). I do not consider myself an experienced or clever programmer,
> but I am able to get by.
> 
> Something I love about Python is that almost everything you do can be
> written in pseudo code then carried across into Python without a great-
> deal of difference.
> 
> But reading through the warts and reading about a lack of "do while
> statements" I also started to ponder about the "'do something' if
> 'true' else 'do this'", and pondered if perhaps this statement could
> do with the including of the keyword do.
> 
> It would clear up the usage of such a statement because it would read
> happily. Or am I making a mountain out of an ant hill?

I doubt this will gain any traction. Similar proposals have been made
before - e.g. http://www.python.org/dev/peps/pep-0315/

But they didn't 

There are a few tricks you can use to emulate the desired behavior without
being to disruptive to the eye. E.g.


while True:
    do_something()
    if condition: break

Granted,

do
  do_something()(
while condition

is a bit more pleasant - but not enough to change the language I'd say.

Diez



More information about the Python-list mailing list