"do" as a keyword
Neil Cerutti
horpner at yahoo.com
Tue Dec 11 10:06:31 EST 2007
On 2007-12-11, cokofreedom at gmail.com <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?
When I use languages that supply do-while or do-until looping
constructs I rarely need them.
I personally miss
for init; condition; next:
more than do-while, but the structured for loop doesn't fit in
Python since init and next would (probably) have to be statements
(or statement suites) rather than expressions. Hence, the cool
innovations of iterators and generators, which otherwise might
not have found a home in Python. I wonder what programming Python
was like before iterators sometimes.
However, did you have an specific need for a do-while construct?
Perhaps we could show you the alternatives.
--
Neil Cerutti
More information about the Python-list
mailing list