问题描述
首先让我说我非常喜欢使用Python。我是第3名学生,并且已经使用python 3个月了(感谢
trac!)。我不认为自己是一个经验丰富或聪明的程序员,
但我能够顺利通过。
我喜欢Python的东西几乎就是你所做的一切可以用伪代码编写的
然后传入Python,而不会产生很大的差价。
但是通读疣和阅读缺乏做什么时候
陈述我也开始思考做某事,如果
''真''其他''做'这个'',并思考是否可能这句话可以
使用关键字do的包含。
它会清除这种语句的用法,因为它会愉快地读取
。或者我是从蚂蚁山上建造一座山?
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?
推荐答案
我怀疑这会获得任何牵引力。之前已经提出了类似的建议
- 例如
但他们没有
您可以使用一些技巧来模拟所需的行为没有
会破坏眼睛。例如
而True:
do_something()
如果条件:休息
授予,
do
do_something()(
条件
多一点愉快 - 但还不足以改变我会说的语言。
Diez
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
当我使用提供do-while或do-until循环的语言
构造时我很少需要它们。
我个人怀念
for init;条件;接下来:
比do-while更多,但是结构化的for循环不适合在
Python中,因为init和next会(可能)必须是声明
(或语句套件)而不是表达式。因此,很好的迭代器和生成器的创新,否则可能是
没有找到Python的家。我想知道在迭代器之前有什么编程Python
就好了。
但是,你是否特别需要一个do-while构造?
也许我们可以告诉你其他选择。
-
Neil Cerutti
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
Python在版本> = 2.5中支持此功能:
Python has support for this in versions >= 2.5:
0
在以前的版本中,你可以使用和/或技巧:
0
In prior versions, you can use the and/or trick:
0
-Tor Erik
0
-Tor Erik
这篇关于"做"作为关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!