Python的“只有一种方法可以做到”哲学不好? [英] Python's "only one way to do it" philosophy isn't good?

查看:54
本文介绍了Python的“只有一种方法可以做到”哲学不好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚读过一篇文章构建强健系统作者:Gerald Jay

Sussman。文章在这里:
http://swiss.csail.mit.edu/classes/s...st-systems.pdf


其中有一个足迹,上面写着:<事实上,人们常常会听到反对将灵活性建设成一个价值的b $ b bm。例如,在计算机语言Python的哲学中它声称:

\应该有一个|并且最好只有一个|显而易见的方法

it。[25]科学确实

通常不会这样进行:例如,在经典力学中,一个

可以构建equa-
拉格朗日或哈密顿量

变分公式来计算运动量。[30]在适用所有三种方法

的情况下,它们相当于
,但每种方法在特定情况下都有其优势。


我不确定这句话是多么合理,我个人喜欢

Python的简洁,强大和优雅。所以我把它放在这里并希望

看到一些鼓舞人心的评论。

I''ve just read an article "Building Robust System" by Gerald Jay
Sussman. The article is here:
http://swiss.csail.mit.edu/classes/s...st-systems.pdf

In it there is a footprint which says:
"Indeed, one often hears arguments against building exibility into an
engineered sys-
tem. For example, in the philosophy of the computer language Python it
is claimed:
\There should be one|and preferably only one|obvious way to do
it."[25] Science does
not usually proceed this way: In classical mechanics, for example, one
can construct equa-
tions of motion using Newtonian vectoral mechanics, or using a
Lagrangian or Hamiltonian
variational formulation.[30] In the cases where all three approaches
are applicable they are
equivalent, but each has its advantages in particular contexts."

I''m not sure how reasonable this statement is and personally I like
Python''s simplicity, power and elegance. So I put it here and hope to
see some inspiring comments.

推荐答案

En Sat,09 Jun 2007 02:49:03 -0300,WaterWalk< to ******** @ 163.com>
$ b $bescribió:
En Sat, 09 Jun 2007 02:49:03 -0300, WaterWalk <to********@163.com>
escribió:

我刚读过一篇文章建立健全系统作者:Gerald Jay

Sussman。文章在这里:
http://swiss.csail.mit.edu/classes/s...st-systems.pdf


其中有一个足迹,上面写着:<事实上,人们常常会听到反对将灵活性建设成一个价值的b $ b bm。例如,在计算机语言Python的哲学中它声称:

\应该有一个|并且最好只有一个|显而易见的方法

it。[25]科学确实

通常不会这样进行:例如,在经典力学中,一个

可以构建equa-
拉格朗日或哈密顿量

变分公式来计算运动量。[30]在适用所有三种方法

的情况下,它们相当于
,但每种方法在特定情况下都有其优势。


我不确定这句话是多么合理,我个人喜欢

Python的简洁,强大和优雅。所以我把它放在这里并希望

看到一些鼓舞人心的评论。
I''ve just read an article "Building Robust System" by Gerald Jay
Sussman. The article is here:
http://swiss.csail.mit.edu/classes/s...st-systems.pdf

In it there is a footprint which says:
"Indeed, one often hears arguments against building exibility into an
engineered sys-
tem. For example, in the philosophy of the computer language Python it
is claimed:
\There should be one|and preferably only one|obvious way to do
it."[25] Science does
not usually proceed this way: In classical mechanics, for example, one
can construct equa-
tions of motion using Newtonian vectoral mechanics, or using a
Lagrangian or Hamiltonian
variational formulation.[30] In the cases where all three approaches
are applicable they are
equivalent, but each has its advantages in particular contexts."

I''m not sure how reasonable this statement is and personally I like
Python''s simplicity, power and elegance. So I put it here and hope to
see some inspiring comments.



我认为关键是你在主题中省略的词:明显的。

应该是一个显而易见的这样做的方式。对于我能记住的第一个我爱的(物理学):如果你有一个小球在球形杯内移动,那么使用笛卡尔正交几乎是疯狂的b $ b坐标和牛顿的

法则来解决它 - 显而易见的方法是使用球面坐标

和拉格朗日公式(或者至少我希望如此 - 肯定

知识渊博的人会发现更多显然这是正确的方法)。

所有经典力学配方都可能是等价的,但在某些情况下,一个更适合其他人。

-

Gabriel Genellina

I think the key is the word you ommited in the subject: "obvious". There
should be one "obvious" way to do it. For what I can remember of my first
love (Physics): if you have a small ball moving inside a spherical cup, it
would be almost crazy to use cartesian orthogonal coordinates and Newton''s
laws to solve it - the "obvious" way would be to use spherical coordinates
and the Lagrangian formulation (or at least I hope so - surely
knowledgeable people will find more "obviously" which is the right way).
All classical mechanics formulations may be equivalent, but in certain
cases one is much more suited that the others.
--
Gabriel Genellina




" WaterWalk" < to ******** @ 163.com在留言中写道

新闻:11 ********************** @ r19g2000prf.googlegr oups.com ...

|我刚读过一篇文章建立稳健系统杰拉尔德杰伊

|苏斯曼。文章在这里:

|
http://swiss.csail.mit.edu/classes/s...st-systems.pdf

|

|其中有一个足迹,上面写着:

| 事实上,人们经常听到反对建立灵活性的论据。

|工程系统 -

| TEM。例如,在计算机语言Python的哲学中它

|声称:


他暗示Python反灵活性是错误的。非常错误..

他应该照镜子。见下文。


| \应该有一个|并且最好只有一个|明显的方式来做

|它。[25]科学确实

|通常不是这样进行的:例如,在经典力学中,一个是
|可以构建equa-

|使用牛顿矢量力学或使用

|的运动拉格朗日或哈密顿量

|变异公式。[30]在所有三种方法的情况下

|是适用的他们是

|等价,但每个在特定情况下都有其优势。


在这些情况下,人们希望有优势的方法是显而易见的b / b
这样做的方式。否则初学者可能会变得像

Buriden的屁股。


所以我认为科学与他声称的不同。而且我没有看到

声明中的任何真实价值,因为我没有看到任何对读者有用的东西

对读者有用,至少在这个片段中没有。


|我不确定这个陈述是多么合理,我个人也喜欢

| Python的简洁,强大和优雅。所以我把它放在这里并希望

|看看一些鼓舞人心的评论。


Sussman先生用Python实际编程了多少,他在哲学的*实施*中发现了什么实际的问题? ?没有什么具体的东西,抱怨就是假的。


但是我觉得这很有趣(而且有点让人抓狂):GJ Sussman是一个人Lisp方言Scheme的发明者,
,这是一种极简主义语言,对于

,有些东西只有一种方法可以做到这一点,更不用说一种明显的方式了。计划

就像物理学一样只有三种方式中的一种。毕竟,如果他们相等,只需要一个。


例如,考虑扫描集合中的项目。在Python中,你可以选择递归(正常或尾部),循环和

语句。对于陈述通常是显而易见的方式,但其他两个

可用于个人品味和特殊情况,例如

走树(其中一个人可能会使用递归来写那个

的生成器可以被for循环使用。在scheme中,我相信你只需要
递归。由于迭代和递归是等价的,为什么两者都有?


Terry Jan Reedy


"WaterWalk" <to********@163.comwrote in message
news:11**********************@r19g2000prf.googlegr oups.com...
| I''ve just read an article "Building Robust System" by Gerald Jay
| Sussman. The article is here:
|
http://swiss.csail.mit.edu/classes/s...st-systems.pdf
|
| In it there is a footprint which says:
| "Indeed, one often hears arguments against building exibility into an
| engineered sys-
| tem. For example, in the philosophy of the computer language Python it
| is claimed:

For him to imply that Python is anti-flexibility is wrong. Very wrong..
He should look in a mirror. See below.

| \There should be one|and preferably only one|obvious way to do
| it."[25] Science does
| not usually proceed this way: In classical mechanics, for example, one
| can construct equa-
| tions of motion using Newtonian vectoral mechanics, or using a
| Lagrangian or Hamiltonian
| variational formulation.[30] In the cases where all three approaches
| are applicable they are
| equivalent, but each has its advantages in particular contexts."

And in those contexts, one would hope that the method with advantages is
somehow the obvious way to do it. Otherwise beginners might become like
Buriden''s ass.

So I dispute that science is as different as he claims. And I do not see
any real value in the statement in that I do not see it saying anything
useful to the reader, at least not in this snippet.

| I''m not sure how reasonable this statement is and personally I like
| Python''s simplicity, power and elegance. So I put it here and hope to
| see some inspiring comments.

How much has Mr. Sussman actually programmed in Python and what actual
problems did he find with the *implementation* of the philosophy? Without
something concrete, the complaint is rather bogus.

But here is what I find funny (and a bit maddening): G. J. Sussman is one
of the inventers of the Lisp dialect Scheme, a minimalist language that for
some things has only one way to do it, let alone one obvious way. Scheme
would be like physics with only one of the three ways. After all, if they
are equivalent, only one is needed.

For example, consider scanning the items in a collection. In Python, you
have a choice of recursion (normal or tail), while loops, and for
statements. For statements are usually the obvious way, but the other two
are available for personal taste and for specially situations such as
walking a tree (where one might use recursion to write the generator that
can then be used by for loops. In scheme, I believe you just have
recursion. Since iteration and recursion are equivalent, why have both?

Terry Jan Reedy


Terry Reedy写道:
Terry Reedy wrote:

在Python中,您可以选择递归(正常或尾部)
In Python, you have a choice of recursion (normal or tail)



请解释一下。我记得在这个新闻组上读到了
$ b ruby(wrt python)的$ b优点是ruby有尾递归,暗示了python没有的
.python是否有完全优化的尾递归,如尾巴所描述的那样
递归维基百科条目?在什么

的情况下可以依靠python解释器识别z优化了b $ b优化尾递归的可能性?


James

=====


免责声明:在帖子中提及多种编程语言

并不意味着作者希望开始语言与语言圣战。

作者没有编程[部分或全部其他语言提到

除了新闻组的语言外]并且对
$没有意见b $ b所述语言的优缺点。


=====

Please explain this. I remember reading on this newsgroup that an
advantage of ruby (wrt python) is that ruby has tail recursion, implying
that python does not. Does python have fully optimized tail recursion as
described in the tail recursion Wikipedia entry? Under what
circumstances can one count on the python interpreter recognizing the
possibility for optimized tail recursion?

James
=====

Disclaimer: Mention of more than one programming language in post does
not imply author''s desire to begin language v. language holy battle. The
author does not program in [some or all of the other languages mentioned
aside from the language topical to the newsgroup] and has no opinions on
the merits or shortcomings of said language or languages.

=====


这篇关于Python的“只有一种方法可以做到”哲学不好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆