PEP-8是否是指南的代码? [英] Is PEP-8 a Code or More of a Guideline?

查看:48
本文介绍了PEP-8是否是指南的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为这个话题开始一个新的主题,以免劫持史蒂夫豪威尔的优秀帖子十小蟒蛇开始的那个

b $ b程序"。


在该主题中,有人建议这些例子应符合PEP-8的风格建议,包括使用

lower_case_with_underscores样式的函数名称。我提出了一些关于这个建议的问题,因为我喜欢这些名字,就像他们的b $ b b一样,但结果是,部分讨论已经进入了
关于PEP-8和命名样式的单独轨道。


我的印象是lower_case_with_underscores是一个

日期推荐,并且最近的做法是更多包含

mixedCase样式标识符。相反,Steven Bethard

让我理顺,说PEP-8过去接受任何一种风格,

但是已被修改为只接受lower_case_with_underscores。


我对这个主题的最新想法可以追溯到马丁诉L?wis

线程 - 不会死的请求有关PEP 3131的反馈,关于

在Py3K中添加对非ASCII标识符的支持。我发布了一个超出

好​​奇心的评论,询问下划线分隔符如何与

Unicode标识符混合,包括实际输入的机制

在非美国键盘上强调。在这一点上,我意识到我把话题放得太远了,所以我决定开始一个新的话题。


史蒂夫,对不起把你的线程拉下来。我希望我们能够将bEP-8相关的任何进一步的讨论(如果这一点值得的话)移动到这个主题的




- Paul

I''m starting a new thread for this topic, so as not to hijack the one
started by Steve Howell''s excellent post titled "ten small Python
programs".

In that thread, there was a suggestion that these examples should
conform to PEP-8''s style recommendations, including use of
lower_case_with_underscores style for function names. I raised some
questions about this suggestion, since I liked the names the way they
were, but as a result, part of the discussion has drifted into a
separate track about PEP-8, and naming styles.

I was under the impression that lower_case_with_underscores was a
dated recommendation, and that recent practice is more inclusive of
mixedCase style identifiers. On the contrary, Steven Bethard
straightened me out, saying that PEP-8 used to accept either style,
but has been amended to accept only lower_case_with_underscores.

My latest thought on the topic relates back to the Martin v. L?wis
thread-that-would-not-die requesting feedback about PEP 3131, on
adding support for non-ASCII identifiers in Py3K. I posted an out-of-
curiosity comment asking about how underscore separators mix with
Unicode identifiers, including the mechanics of actually typing an
underscore on a non-US keyboard. At this point, I realized that I was
taking things too far off-topic, so I decided to start a new thread.

Steve, sorry for taking your thread down a rathole. I hope we can
move any further PEP-8-related discussion (if the point merits any) to
this thread.

-- Paul

推荐答案

Paul McGuire schrieb:
Paul McGuire schrieb:

我正在为这个话题开始一个新的主题,以免劫持史蒂夫豪威尔的优秀帖子十小Python

程序" ;.


在该主题中,有人建议这些例子应符合PEP-8的风格建议,包括使用

lower_case_with_underscores函数名称的样式。我提出了一些关于这个建议的问题,因为我喜欢这些名字,就像他们的b $ b b一样,但结果是,部分讨论已经进入了
关于PEP-8和命名样式的单独轨道。


我的印象是lower_case_with_underscores是一个

日期推荐,并且最近的做法是更多包含

mixedCase样式标识符。相反,Steven Bethard

让我理顺,说PEP-8过去接受任何一种风格,

但是已被修改为只接受lower_case_with_underscores。


我对这个主题的最新想法可以追溯到马丁诉L?wis

线程 - 不会死的请求有关PEP 3131的反馈,关于

在Py3K中添加对非ASCII标识符的支持。我发布了一个超出

好​​奇心的评论,询问下划线分隔符如何与

Unicode标识符混合,包括实际输入的机制

在非美国键盘上强调。在这一点上,我意识到我把话题放得太远了,所以我决定开始一个新的话题。


史蒂夫,对不起把你的线程拉下来。我希望我们能够将bEP-8相关的任何进一步的讨论(如果这一点值得的话)移动到这个主题的




- Paul

I''m starting a new thread for this topic, so as not to hijack the one
started by Steve Howell''s excellent post titled "ten small Python
programs".

In that thread, there was a suggestion that these examples should
conform to PEP-8''s style recommendations, including use of
lower_case_with_underscores style for function names. I raised some
questions about this suggestion, since I liked the names the way they
were, but as a result, part of the discussion has drifted into a
separate track about PEP-8, and naming styles.

I was under the impression that lower_case_with_underscores was a
dated recommendation, and that recent practice is more inclusive of
mixedCase style identifiers. On the contrary, Steven Bethard
straightened me out, saying that PEP-8 used to accept either style,
but has been amended to accept only lower_case_with_underscores.

My latest thought on the topic relates back to the Martin v. L?wis
thread-that-would-not-die requesting feedback about PEP 3131, on
adding support for non-ASCII identifiers in Py3K. I posted an out-of-
curiosity comment asking about how underscore separators mix with
Unicode identifiers, including the mechanics of actually typing an
underscore on a non-US keyboard. At this point, I realized that I was
taking things too far off-topic, so I decided to start a new thread.

Steve, sorry for taking your thread down a rathole. I hope we can
move any further PEP-8-related discussion (if the point merits any) to
this thread.

-- Paul



我更喜欢mixedCaseStyle,我认为应该是标准,因为这个

风格通常是

用于所有主要的语言,例如Java,C ++,C#。

它缩短了标识符但保留了完整的含义。

I prefer mixedCaseStyle, and I think that should be "standard", as this
style is commonly
used in all "major" languages , for example Java,C++,C#.
It shortens the identifiers but leaves the meaning intact.


Stefan Sonnenberg- Carstens写道:
Stefan Sonnenberg-Carstens wrote:

Paul McGuire schrieb:
Paul McGuire schrieb:

>我正在开始一个新线程这个主题,以免劫持由史蒂夫豪威尔的优秀帖子十个小Python的程序开始的那个。

在那个帖子里,有一个建议这些示例应符合PEP-8的样式建议,包括使用
lower_case_with_underscores样式的函数名称。我提出了一些关于这个建议的问题,因为我喜欢这些名字的名字,但结果,部分讨论已经进入了关于PEP-8的单独轨道,和命名样式。
>I''m starting a new thread for this topic, so as not to hijack the one
started by Steve Howell''s excellent post titled "ten small Python
programs".

In that thread, there was a suggestion that these examples should
conform to PEP-8''s style recommendations, including use of
lower_case_with_underscores style for function names. I raised some
questions about this suggestion, since I liked the names the way they
were, but as a result, part of the discussion has drifted into a
separate track about PEP-8, and naming styles.



我更喜欢mixedCaseStyle,我认为应该是标准,因为这个

样式通常是

在所有主要中使用语言,例如Java,C ++,C#。

它缩短了标识符但保留了完整的含义。


I prefer mixedCaseStyle, and I think that should be "standard", as this
style is commonly
used in all "major" languages , for example Java,C++,C#.
It shortens the identifiers but leaves the meaning intact.



under_score_names的参数通常是非母语人士

可以更容易地找到单词边界。不是非母语人士

;-)我无法验证那一个,但鉴于目前花费的金额为b $ b,这是非常合理的

语言的自动分词研究,如中文。 =)


STeVe

The argument for under_score_names is usually that non-native speakers
can more easily find the word boundaries. Not being a non-native speaker
;-) I can''t verify that one, but it''s pretty plausible given the current
amount of money spent on research on automatic word-segmentation for
languages like Chinese. =)

STeVe


Paul McGuire写道:
Paul McGuire wrote:

我的印象是lower_case_with_underscores是一个

日期推荐,并且最近的做法更多包含了

mixedCase样式标识符。相反,Steven Bethard

让我理顺,说PEP-8曾经接受任何一种风格,但是已经修改为仅接受lower_case_with_underscores。
I was under the impression that lower_case_with_underscores was a
dated recommendation, and that recent practice is more inclusive of
mixedCase style identifiers. On the contrary, Steven Bethard
straightened me out, saying that PEP-8 used to accept either style,
but has been amended to accept only lower_case_with_underscores.



下划线比任何字母数字字符更难打字。

因此我支持在打字困难的情况下使用它们

可取(例如,魔术方法名称),我在所有其他

情况下讨厌它们。


-

--OKB(不是okblacke)

Brendan Barnwell

不要跟随路径走向何方。转而去,那里有

没有路径,并留下痕迹。

- author unknown

Underscores are harder to type than any alphanumeric character.
Thus I support their use in situations where difficulty of typing is
desirable (e.g., magic method names) and I detest them in all other
situations.

--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown


这篇关于PEP-8是否是指南的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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