Contents
  1. 1. 标题
  2. 2. 疑难句
  3. 3. 单词本

标题

译文标题:Python中你不应该做的事

原文标题:Things You Shouldn’t Do in Python

原文链接: https://www.airpair.com/python/posts/things-not-to-do-in-python

疑难句

1

“Premature optimization is the root of all evil (or at least most of it) in programming.” — Donald Knuth

“在编程中过早的优化是一切(或至少大部分)罪恶的根源。” - 高德纳

2

A word of advice: If you program outside the conventional rules, make heavy use of syntax checkers and secondary tools to ensure that the only code that disobeys the rules is precisely the code you intended.

一句忠告:如果您在传统的规则之外进行编程,请不要吝啬大量使用语法检查和辅助工具,以确保唯一违背规则的那些代码能达到所预期的结果。

3

“By understanding a machine-oriented language, the programmer will tend to use a much more efficient method; it is much closer to reality.” (Knuth again)

“通过了解一个面向机器的语言,程序员会倾向于使用一种更有效的方法,它更接近现实”。(又是克努特)

4

Standard python dictionaries are very useful. However, sometimes it is more convenient to use unquoted class member names to gain access to data stored in dictionaries rather than brackets and quoted strings.

标准的Python字典是很有用。但是有时使用不带引号的类成员的名字来访问在字典中存储的数据比括号和引用字符串数据更加方便。

5

Conclusion

There are aesthetics with strong proponents and opponents but:

  • There really are no objective Do’s and Don’ts in programming.
  • Anything for which there is machine code is permitted.
  • Learn new “dirty tricks”, not just “good practices”.
  • Use what works and make it useful for others.
  • Don’t make it cost too much (unless it pleases you to do so).
  • Explain the why and how of unconventional methods with care and efficiency.
  • Accept criticism gladly, because surely you will be rightly criticized.
    Don’t just work… PLAY! Make mistakes!

结论

有着相当一部分很强烈的支持和反对的美学,但是请注意:

  • 在编程中真的有没有客观上的Do’s和Don’ts。
  • 任何事情上使用机器代码都是允许的。
  • 学习新的“肮脏把戏”,而不仅仅是“良好做法”。
  • 使用有效的工具,并使其让他人也可用。
  • 不要为一件事花费太多(除非你高兴这样做)。
  • 谨慎而效率地解释为何以及如何使用那些非常规的方法。
  • 开心接受批评,因为你一定会得到正确的批评。
  • 不要只是工作…去享受!去犯错误!

6

There will always be people who will seek solutions to problems come hell or high water and other people who will wag a finger and look sternly over their lorgnettes at the egregious methods used by the problem solvers. This battle between hackers and pedants inevitably results in a lively history of online discussions containing very strong opinions and, sometimes even, useful examples.

总是会有一些无论如何困难都在寻求解决问题办法的人和其他对着提出惊人方案的解决者一脸正色地在长柄眼镜上摇摇手指的人。黑客和学究之间的这一战不可避免地会导致一些强烈意见和网上讨论,有时甚至是有用的案例。

单词本

come hell or high water 就算天崩地裂/无论如何困难

Duck typing wiki

premature 过早的

optimization 优化

lorgnettes 长柄眼镜

pedants 卖弄知识的人

inevitably 不可避免的

Impedance 阻抗

Mismatch 不协调的

cleverness 灵巧

obfuscation 混淆

Contents
  1. 1. 标题
  2. 2. 疑难句
  3. 3. 单词本