10101111# Freesand Leo <[email protected] >, 20181212# yuxin wang <[email protected] >, 201913+ # chen_chao <[email protected] >, 20191314#
1415#, fuzzy
1516msgid ""
@@ -18,7 +19,7 @@ msgstr ""
1819"Report-Msgid-Bugs-To : \n "
1920"POT-Creation-Date : 2019-01-01 10:14+0900\n "
2021"PO-Revision-Date : 2017-02-16 17:44+0000\n "
21- "Last-Translator : yuxin wang <wangyuxinwhy @gmail.com>, 2019\n "
22+ "Last-Translator : chen_chao <wenbushi @gmail.com>, 2019\n "
2223"Language-Team : Chinese (China) (https://www.transifex.com/python-doc/teams/5390/zh_CN/)\n "
2324"MIME-Version : 1.0\n "
2425"Content-Type : text/plain; charset=UTF-8\n "
@@ -105,6 +106,8 @@ msgid ""
105106"and Python are languages that support object-oriented programming, but don't"
106107" force the use of object-oriented features."
107108msgstr ""
109+ "**面向对象**程序会操作一组对象。 对象拥有内部状态,并能够以某种方式支持请求和修改这个内部状态的方法。Smalltalk 和 JAVA "
110+ "都是面向对象的语言。 C++ 和 Python 支持面向对象编程,但并不强制使用面向对象特性。"
108111
109112#: ../../howto/functional.rst:41
110113msgid ""
@@ -114,6 +117,8 @@ msgid ""
114117"known functional languages include the ML family (Standard ML, OCaml, and "
115118"other variants) and Haskell."
116119msgstr ""
120+ "**函数式**编程则将一个问题分解成一系列函数。 理想情况下,函数只接受输入并输出结果,对一个给定的输入也不会有影响输出的内部状态。著名的函数式语言有 "
121+ "ML 家族(Standard ML,Ocaml以及其他变种)和 Haskell。"
117122
118123#: ../../howto/functional.rst:47
119124msgid ""
@@ -127,6 +132,10 @@ msgid ""
127132" GUI might be object-oriented while the processing logic is procedural or "
128133"functional, for example."
129134msgstr ""
135+ "一些语言的设计者选择强调一种特定的编程方式。 这通常会让以不同的方式来编写程序变得困难。其他多范式语言则支持几种不同的编程方式。Lisp,C++ 和 "
136+ "Python "
137+ "都是多范式语言;使用这些语言,你可以编写主要为过程式,面向对象或者函数式的程序和函数库。在大型程序中,不同的部分可能会采用不同的方式编写;比如 GUI "
138+ "可能是面向对象的而处理逻辑则是过程式或者函数式。"
130139
131140#: ../../howto/functional.rst:58
132141msgid ""
@@ -138,6 +147,7 @@ msgid ""
138147"Avoiding side effects means not using data structures that get updated as a "
139148"program runs; every function's output must only depend on its input."
140149msgstr ""
150+ "在函数式程序里,输入流经一系列函数。每个函数接受输入并输出结果。函数式风格反对使用带有副作用的函数,这些副作用会修改内部状态,或者引起一些无法体现在函数的返回值中的变化。完全不产生副作用的函数被称作“纯函数”。消除副作用意味着不能使用随程序运行而更新的数据结构;每个函数的输出必须只依赖于输入。"
141151
142152#: ../../howto/functional.rst:66
143153msgid ""
@@ -149,6 +159,9 @@ msgid ""
149159"called for their side effects of sending some text to the screen or pausing "
150160"execution for a second."
151161msgstr ""
162+ "一些语言对纯洁性要求非常严格,以至于没有像 ``a=3`` 或 ``c = a + b`` 这样的赋值表达式,但是完全消除副作用非常困难。 "
163+ "比如,显示在屏幕上或者写到磁盘文件中都是副作用。举个例子,在 Python 里,调用函数 :func:`print` 或者 "
164+ ":func:`time.sleep` 并不会返回有用的结果;它们的用途只在于副作用,向屏幕发送一段文字或暂停一秒钟。"
152165
153166#: ../../howto/functional.rst:74
154167msgid ""
@@ -159,6 +172,8 @@ msgid ""
159172"assignments to local variables, but won't modify global variables or have "
160173"other side effects."
161174msgstr ""
175+ "函数式风格的 Python 程序并不会极端到消除所有 I/O "
176+ "或者赋值的程度;相反,他们会提供像函数式一样的接口,但会在内部使用非函数式的特性。比如,函数的实现仍然会使用局部变量,但不会修改全局变量或者有其他副作用。"
162177
163178#: ../../howto/functional.rst:80
164179msgid ""
@@ -171,39 +186,41 @@ msgid ""
171186"approaches by writing functions that take and return instances representing "
172187"objects in your application (e-mail messages, transactions, etc.)."
173188msgstr ""
189+ "函数式编程可以被认为是面向对象编程的对立面。对象就像是小胶囊,包裹着内部状态和随之而来的能让你修改这个内部状态的一组调用方法,以及由正确的状态变化所构成的程序。函数式编程希望尽可能地消除状态变化,只和流经函数的数据打交道。在"
190+ " Python 里你可以把两种编程方式结合起来,在你的应用(电子邮件信息,事务处理)中编写接受和返回对象实例的函数。"
174191
175192#: ../../howto/functional.rst:89
176193msgid ""
177194"Functional design may seem like an odd constraint to work under. Why should"
178195" you avoid objects and side effects? There are theoretical and practical "
179196"advantages to the functional style:"
180- msgstr ""
197+ msgstr "函数式设计在工作中看起来是个奇怪的约束。为什么你要消除对象和副作用呢?不过函数式风格有其理论和实践上的优点: "
181198
182199#: ../../howto/functional.rst:93
183200msgid "Formal provability."
184- msgstr ""
201+ msgstr "形式证明。 "
185202
186203#: ../../howto/functional.rst:94
187204msgid "Modularity."
188- msgstr ""
205+ msgstr "模块化。 "
189206
190207#: ../../howto/functional.rst:95
191208msgid "Composability."
192- msgstr ""
209+ msgstr "组合性。 "
193210
194211#: ../../howto/functional.rst:96
195212msgid "Ease of debugging and testing."
196- msgstr ""
213+ msgstr "易于调试和测试。 "
197214
198215#: ../../howto/functional.rst:100
199216msgid "Formal provability"
200- msgstr ""
217+ msgstr "形式证明 "
201218
202219#: ../../howto/functional.rst:102
203220msgid ""
204221"A theoretical benefit is that it's easier to construct a mathematical proof "
205222"that a functional program is correct."
206- msgstr ""
223+ msgstr "一个理论上的优点是,构造数学证明来说明函数式程序是正确的相对更容易些。 "
207224
208225#: ../../howto/functional.rst:105
209226msgid ""
@@ -214,6 +231,7 @@ msgid ""
214231"looks right; the goal is instead a rigorous proof that a program produces "
215232"the right result for all possible inputs."
216233msgstr ""
234+ "很长时间,研究者们对寻找证明程序正确的数学方法都很感兴趣。这和通过大量输入来测试,并得出程序的输出基本正确,或者阅读一个程序的源代码然后得出代码看起来没问题不同;相反,这里的目标是一个严格的证明,证明程序对所有可能的输入都能给出正确的结果。"
217235
218236#: ../../howto/functional.rst:112
219237msgid ""
@@ -225,14 +243,16 @@ msgid ""
225243"This continues until you reach the end of the program, at which point the "
226244"invariants should match the desired conditions on the program's output."
227245msgstr ""
246+ "证明程序正确性所用到的技术是写出**不变量**,也就是对于输入数据和程序中的变量永远为真的特性。然后对每行代码,你说明这行代码执行前的不变量 X 和 Y"
247+ " 以及执行后稍有不同的不变量 X' 和 Y' 为真。如此一直到程序结束,这时候在程序的输出上,不变量应该会与期望的状态一致。"
228248
229249#: ../../howto/functional.rst:120
230250msgid ""
231251"Functional programming's avoidance of assignments arose because assignments "
232252"are difficult to handle with this technique; assignments can break "
233253"invariants that were true before the assignment without producing any new "
234254"invariants that can be propagated onward."
235- msgstr ""
255+ msgstr "函数式编程之所以要消除赋值,是因为赋值在这个技术中难以处理;赋值可能会破坏赋值前为真的不变量,却并不产生任何可以传递下去的新的不变量。 "
236256
237257#: ../../howto/functional.rst:125
238258msgid ""
@@ -245,10 +265,14 @@ msgid ""
245265"the question of verifying the proof; maybe there's an error in it, and you "
246266"wrongly believe you've proved the program correct."
247267msgstr ""
268+ "不幸的是,证明程序的正确性很大程度上是经验性质的,而且和 Python "
269+ "软件无关。即使是微不足道的程序都需要几页长的证明;一个中等复杂的程序的正确性证明会非常庞大,而且,极少甚至没有你日常所使用的程序(Python "
270+ "解释器,XML "
271+ "解析器,浏览器)的正确性能够被证明。即使你写出或者生成一个证明,验证证明也会是一个问题;里面可能出了差错,而你错误地相信你证明了程序的正确性。"
248272
249273#: ../../howto/functional.rst:136
250274msgid "Modularity"
251- msgstr ""
275+ msgstr "模块化 "
252276
253277#: ../../howto/functional.rst:138
254278msgid ""
@@ -258,14 +282,15 @@ msgid ""
258282"thing than a large function that performs a complicated transformation. "
259283"Small functions are also easier to read and to check for errors."
260284msgstr ""
285+ "函数式编程的一个更实用的优点是,它强制你把问题分解成小的方面。因此程序会更加模块化。相对于一个进行了复杂变换的大型函数,一个小的函数更明确,更易于编写。小函数也更易于阅读和检查错误。"
261286
262287#: ../../howto/functional.rst:146
263288msgid "Ease of debugging and testing"
264- msgstr ""
289+ msgstr "易于调试和测试 "
265290
266291#: ../../howto/functional.rst:148
267292msgid "Testing and debugging a functional-style program is easier."
268- msgstr ""
293+ msgstr "测试和调试函数式程序相对来说更容易。 "
269294
270295#: ../../howto/functional.rst:150
271296msgid ""
@@ -275,6 +300,7 @@ msgid ""
275300"intermediate inputs and outputs to quickly isolate the function that's "
276301"responsible for a bug."
277302msgstr ""
303+ "调试很简单是因为函数通常都很小而且清晰明确。当程序无法工作的时候,每个函数都是一个可以检查数据是否正确的接入点。你可以通过查看中间输入和输出迅速找到出错的函数。"
278304
279305#: ../../howto/functional.rst:155
280306msgid ""
@@ -283,6 +309,7 @@ msgid ""
283309"before running a test; instead you only have to synthesize the right input "
284310"and then check that the output matches expectations."
285311msgstr ""
312+ "测试更容易是因为每个函数都是单元测试的潜在目标。在执行测试前,函数并不依赖于需要重现的系统状态;相反,你只需要给出正确的输入,然后检查输出是否和期望的结果一致。"
286313
287314#: ../../howto/functional.rst:162
288315msgid "Composability"
0 commit comments