冲突的指导方针

发布于 2024-07-15 18:28:09 字数 292 浏览 6 评论 0原文

在使用 Python 进行编码时,最好遵循 PEP8 的指南进行编码。

在为 Symbian 编码时,最好遵循其编码标准。

但是,当我为 PyS60 编写代码时,应该遵循哪些准则? 到目前为止,我一直在关注 PEP8,但是这段代码显示了相反的情况。 我需要修改我的代码吗?

While coding in Python it's better to code by following the guidelines of PEP8.

And while coding for Symbian it's better to follow its coding standards.

But when I code for PyS60 which guidelines should I follow? Till now I have been following PEP8, but this code shows the opposite. Do I need to rework my code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

十雾 2024-07-22 18:28:09

我在您的代码示例中没有看到任何明显伪造的内容。 这不是我会使用的风格,但也不难阅读,而且与 PEP8 相差不远,我称之为“相反”。

PEP8 不应被视为所有代码都必须逐个严格遵守的硬性法律。 它是可读 Python 的基线。 当您成为一名 Java 程序员并对使每个运算符周围的间距保持一致感到不安时,请返回并再次阅读 PEP8 的开头。 与大妖精的那点事。

不要沉迷于对功能性、可读性以及至少与 PEP8 大致相同的代码进行冗长的“修改”。

I don't see anything in your code sample that is obviously bogus. It's not the style I'd use, but neither is it hard to read, and it's not so far from PEP8 that I'd call it “the opposite”.

PEP8 shouldn't be seen as hard-and-fast law to which all code must conform, character by rigid character. It is a baseline for readable Python. When you go a little bit Java-programmer and get that antsiness about making the spacing around every operator consistent, go back and read the start of PEP8 again. The bit with the hobgoblin.

Don't get hung up on lengthy ‘reworking’ of code that is functional, readable, and at least in the same general vicinity as PEP8.

红衣飘飘貌似仙 2024-07-22 18:28:09

“我需要修改我的代码吗?”

它会给你的代码返工增加价值吗?

有多少人会帮助您开发代码,他们

A)不知道 PEP 8

B)只知道 PyS60 编码标准,因为这是他们见过的唯一代码。

C

) 不能教授任何与 PyS60 编码标准不同的东西?

列出所有与您一起工作且符合所有三个标准的人员。 然后决定哪个更便宜:重新编写代码或解雇它们。

"Do I need to rework my code?"

Does it add value to rework you code?

How many folks will help you develop code who

A) don't know PEP 8

B) only know PyS60 coding standards because that's the only code they've ever seen.

and

C) cannot be taught anything different than the PyS60 coding standards?

List all the people who you'll work with that meet all three criteria. Then decide which is cheaper: rework your code or fire them.

揪着可爱 2024-07-22 18:28:09

使用您最常连接的 API 的风格。 这是一个适用于大多数地方的简单规则(您可以在其中看到代码,即 Java/C# 有点难(呃)..:)

Use the style of the API(s) you're interfacing the most. That's a simple rule that works in most places (where you can see the code, i.e. Java/C# is a bit hard(er).. :)

风渺 2024-07-22 18:28:09

我想说使用 PEP8,但正如上面提到的,不要太执着于它。 在 symbian c++ 中编码时,您应该使用 symbian 编码标准,但如果您的程序仅在该平台上运行则不一定。 不要混淆 symbian 操作系统和 symbian c++(伪)语言。

i'd say use PEP8, but as mentioned above, don't get too hung up on it. when coding IN symbian c++ you should use symbian coding standards, but not necessarily if your program is merely running on the platform. don't get confused between symbian the OS and symbian c++ the (psuedo) language.

岁月无声 2024-07-22 18:28:09

您的示例代码只是该人的个人风格。 它不遵循官方 PyS60 编码约定,不存在这样的事情! 写任何能给你最好结果的风格。

话虽如此,我还是建议您使用 PEP8,但前提是您打算使用 pylint 来给您的项目带来更多信心。

我只做过 PyS60 的东西,从来没有做过真正的 python。 使用 pylint 来加快开发时间,并在我在现实生活中遇到一些潜在缺陷之前自动指出它们。

Your example code is just that person's personal style. It's NOT following official PyS60 coding convension, there is no such a thing! Write whatever style gives you the best results.

Having said that I would recommend using PEP8, but only if you plan to use pylint to give you some additional confidence in your project.

I've done nothing but PyS60 stuff, never real python. Used pylint to speedup development time and to automatically point me some potential defects before I run into them in real life.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文