33# This file is distributed under the same license as the Python package.
44# FIRST AUTHOR <EMAIL@ADDRESS>, 2017.
55#
6- #, fuzzy
76msgid ""
87msgstr ""
98"Project-Id-Version : Python 3.6\n "
@@ -18,23 +17,21 @@ msgstr ""
1817"Generated-By : Babel 2.17.0\n "
1918
2019#: ../../library/numbers.rst:2
21- #, fuzzy
2220msgid ":mod:`!numbers` --- Numeric abstract base classes"
23- msgstr ":mod:`numbers` --- 숫자 추상 베이스 클래스"
21+ msgstr ":mod:`! numbers` --- 숫자 추상 베이스 클래스"
2422
2523#: ../../library/numbers.rst:7
2624msgid "**Source code:** :source:`Lib/numbers.py`"
2725msgstr "**소스 코드:** :source:`Lib/numbers.py`"
2826
2927#: ../../library/numbers.rst:11
30- #, fuzzy
3128msgid ""
3229"The :mod:`!numbers` module (:pep:`3141`) defines a hierarchy of numeric "
3330":term:`abstract base classes <abstract base class>` which progressively "
3431"define more operations. None of the types defined in this module are "
3532"intended to be instantiated."
3633msgstr ""
37- ":mod:`numbers` 모듈(:pep:`3141`)은 숫자에 대한 :term:`추상 베이스 클래스 <abstract base "
34+ ":mod:`! numbers` 모듈(:pep:`3141`)은 숫자에 대한 :term:`추상 베이스 클래스 <abstract base "
3835"class>` 의 계층 구조를 정의합니다. 계층 구조가 깊어질수록 더 많은 연산이 정의되어 있습니다. 이 모듈에 정의된 모든 형은 "
3936"인스턴스로 만들 수 없습니다."
4037
@@ -52,7 +49,6 @@ msgid "The numeric tower"
5249msgstr "숫자 계층"
5350
5451#: ../../library/numbers.rst:27
55- #, fuzzy
5652msgid ""
5753"Subclasses of this type describe complex numbers and include the "
5854"operations that work on the built-in :class:`complex` type. These are: "
@@ -63,8 +59,8 @@ msgid ""
6359msgstr ""
6460"이 서브 클래스는 복소수를 표현하고 내장 :class:`complex` 형에 사용되는 연산을 포함합니다. 여기에는 "
6561":class:`complex` 와 :class:`bool` 형으로의 변환과 :attr:`.real`, :attr:`.imag`, "
66- "``+``, ``-``, ``*``, ``/``, :func:`abs`, :meth:`conjugate`, ``==` `, "
67- "``!=`` 이 포함됩니다. ``-`` 와 ``!=`` 를 제외하고는 모두 추상입니다. "
62+ "``+``, ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, "
63+ "``==``, `` !=`` 이 포함됩니다. ``-`` 와 ``!=`` 를 제외하고는 모두 추상입니다."
6864
6965#: ../../library/numbers.rst:35
7066msgid "Abstract. Retrieves the real component of this number."
@@ -81,11 +77,10 @@ msgid ""
8177msgstr "추상 메서드. 켤레 복소수를 반환합니다. 예를 들어 ``(1+3j).conjugate() == (1-3j)`` 입니다."
8278
8379#: ../../library/numbers.rst:49
84- #, fuzzy
8580msgid ""
8681"To :class:`Complex`, :class:`!Real` adds the operations that work on real"
8782" numbers."
88- msgstr ":class:`Real` 클래스는 :class:`Complex` 클래스에 실수 연산을 추가합니다."
83+ msgstr ":class:`! Real` 클래스는 :class:`Complex` 클래스에 실수 연산을 추가합니다."
8984
9085#: ../../library/numbers.rst:52
9186msgid ""
@@ -106,15 +101,14 @@ msgstr ""
106101":meth:`~Complex.conjugate` 를 위한 기본값을 제공합니다."
107102
108103#: ../../library/numbers.rst:62
109- #, fuzzy
110104msgid ""
111105"Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and "
112106":attr:`~Rational.denominator` properties. It also provides a default for "
113107":func:`float`."
114108msgstr ""
115109":class:`Real` 의 하위 형이고 :attr:`~Rational.numerator` 와 "
116- ":attr:`~Rational.denominator` 프로퍼티가 추가됩니다. 이 프로퍼티는 기약 분수의 값이어야 합니다. 또한 "
117- ":func:`float` 함수를 위한 기본값으로 사용됩니다 ."
110+ ":attr:`~Rational.denominator` 프로퍼티가 추가됩니다. 또한 :func:`float` 함수를 위한 기본값을 "
111+ "제공합니다 ."
118112
119113#: ../../library/numbers.rst:66
120114msgid ""
@@ -128,7 +122,6 @@ msgid "Abstract."
128122msgstr "프로퍼티(추상 메서드)"
129123
130124#: ../../library/numbers.rst:81
131- #, fuzzy
132125msgid ""
133126"Subtypes :class:`Rational` and adds a conversion to :class:`int`. "
134127"Provides defaults for :func:`float`, :attr:`~Rational.numerator`, and "
@@ -138,16 +131,14 @@ msgid ""
138131msgstr ""
139132":class:`Rational` 의 하위 형이고 :class:`int` 클래스로 변환 기능이 추가됩니다. :func:`float`,"
140133" :attr:`~Rational.numerator`, :attr:`~Rational.denominator` 를 위한 기본값을 "
141- "제공합니다. ``**`` 를 위한 메서드와 비트 연산 ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~`` "
142- "를 추가합니다."
134+ "제공합니다. 모듈러스가 있는 :func:`pow` \\ 를 위한 추상 메서드와 비트 연산 ``<<``, ``>>``, ``&``, "
135+ "``^``, ``|``, ``~`` 를 추가합니다."
143136
144137#: ../../library/numbers.rst:89
145- #, fuzzy
146138msgid "Notes for type implementers"
147- msgstr "형 구현을 위한 주의 사항"
139+ msgstr "형 구현자를 위한 주의 사항"
148140
149141#: ../../library/numbers.rst:91
150- #, fuzzy
151142msgid ""
152143"Implementers should be careful to make equal numbers equal and hash them "
153144"to the same values. This may be subtle if there are two different "
@@ -172,6 +163,16 @@ msgid ""
172163" # simple fractions.\n"
173164" return hash((self.numerator, self.denominator))"
174165msgstr ""
166+ "def __hash__(self):\n"
167+ " if self.denominator == 1:\n"
168+ " # 정수입니다.\n"
169+ " return hash(self.numerator)\n"
170+ " # 비싼 검사이지만, 확실히 맞습니다.\n"
171+ " if self == float(self):\n"
172+ " return hash(float(self))\n"
173+ " else:\n"
174+ " # 간단한 분수에서의 높은 충돌률을 피하기위해 튜플의 해시를 사용합니다.\n"
175+ " return hash((self.numerator, self.denominator))"
175176
176177#: ../../library/numbers.rst:110
177178msgid "Adding More Numeric ABCs"
@@ -191,13 +192,14 @@ msgid ""
191192"class MyFoo(Complex): ...\n"
192193"MyFoo.register(Real)"
193194msgstr ""
195+ "class MyFoo(Complex): ...\n"
196+ "MyFoo.register(Real)"
194197
195198#: ../../library/numbers.rst:124
196199msgid "Implementing the arithmetic operations"
197200msgstr "산술 연산 구현"
198201
199202#: ../../library/numbers.rst:126
200- #, fuzzy
201203msgid ""
202204"We want to implement the arithmetic operations so that mixed-mode "
203205"operations either call an implementation whose author knew about the "
@@ -207,8 +209,9 @@ msgid ""
207209"defined as::"
208210msgstr ""
209211"다른 형에 대한 연산은 두 인자의 형에 관해 알고 있는 구현을 호출하거나 두 인자를 가장 비슷한 내장형으로 변환하여 연산하도록 산술"
210- " 연산을 구현하는 것이 좋습니다. :class:`Integral` 클래스의 하위 형일 경우에 :meth:`__add__` 와 "
211- ":meth:`__radd__` 메서드는 다음과 같이 정의되어야 함을 의미합니다::"
212+ " 연산을 구현하는 것이 좋습니다. :class:`Integral` 클래스의 하위 형일 경우에 "
213+ ":meth:`~object.__add__` 와 :meth:`~object.__radd__` 메서드는 다음과 같이 정의되어야 함을 "
214+ "의미합니다::"
212215
213216#: ../../library/numbers.rst:133
214217msgid ""
@@ -236,6 +239,29 @@ msgid ""
236239" else:\n"
237240" return NotImplemented"
238241msgstr ""
242+ "class MyIntegral(Integral):\n"
243+ "\n"
244+ " def __add__(self, other):\n"
245+ " if isinstance(other, MyIntegral):\n"
246+ " return do_my_adding_stuff(self, other)\n"
247+ " elif isinstance(other, OtherTypeIKnowAbout):\n"
248+ " return do_my_other_adding_stuff(self, other)\n"
249+ " else:\n"
250+ " return NotImplemented\n"
251+ "\n"
252+ " def __radd__(self, other):\n"
253+ " if isinstance(other, MyIntegral):\n"
254+ " return do_my_adding_stuff(other, self)\n"
255+ " elif isinstance(other, OtherTypeIKnowAbout):\n"
256+ " return do_my_other_adding_stuff(other, self)\n"
257+ " elif isinstance(other, Integral):\n"
258+ " return int(other) + int(self)\n"
259+ " elif isinstance(other, Real):\n"
260+ " return float(other) + float(self)\n"
261+ " elif isinstance(other, Complex):\n"
262+ " return complex(other) + complex(self)\n"
263+ " else:\n"
264+ " return NotImplemented"
239265
240266#: ../../library/numbers.rst:158
241267msgid ""
@@ -251,34 +277,31 @@ msgstr ""
251277"비슷하게 ``b : B <: Complex`` 입니다. ``a + b`` 인 경우를 생각해 보겠습니다:"
252278
253279#: ../../library/numbers.rst:165
254- #, fuzzy
255280msgid ""
256281"If ``A`` defines an :meth:`~object.__add__` which accepts ``b``, all is "
257282"well."
258- msgstr "만약 ``A`` 가 ``b`` 를 받는 :meth:`__add__` 메서드를 정의했다면 모든 것이 문제없이 처리됩니다."
283+ msgstr "만약 ``A`` 가 ``b`` 를 받는 :meth:`~object. __add__` 메서드를 정의했다면 모든 것이 문제없이 처리됩니다."
259284
260285#: ../../library/numbers.rst:167
261- #, fuzzy
262286msgid ""
263287"If ``A`` falls back to the boilerplate code, and it were to return a "
264288"value from :meth:`~object.__add__`, we'd miss the possibility that ``B`` "
265289"defines a more intelligent :meth:`~object.__radd__`, so the boilerplate "
266290"should return :data:`NotImplemented` from :meth:`!__add__`. (Or ``A`` may"
267291" not implement :meth:`!__add__` at all.)"
268292msgstr ""
269- "``A`` 가 기본구조 코드로 진입하고 :meth:`__add__`\\ 로 부터 어떤 값을 반환한다면 ``B`` 가 똑똑하게 정의한 "
270- ":meth:`__radd__` 메서드를 놓칠 수 있습니다. 이를 피하려면 기본구조는 :meth:`__add__` 에서 "
271- ":const:` NotImplemented` 를 반환해야 합니다. (또는 ``A`` 가 :meth:`__add__` 메서드를 전혀 "
272- "구현하지 않을 수도 있습니다.)"
293+ "``A`` 가 기본구조 코드로 진입하고 :meth:`~object. __add__`\\ 로 부터 어떤 값을 반환한다면 ``B`` 가 "
294+ "똑똑하게 정의한 :meth:`~object. __radd__` 메서드를 놓칠 수 있습니다. 이를 피하려면 기본구조는 "
295+ ":meth:`!__add__` 에서 :data:` NotImplemented` 를 반환해야 합니다. (또는 ``A`` 가 "
296+ ":meth:`!__add__` 메서드를 전혀 구현하지 않을 수도 있습니다.)"
273297
274298#: ../../library/numbers.rst:173
275- #, fuzzy
276299msgid ""
277300"Then ``B``'s :meth:`~object.__radd__` gets a chance. If it accepts ``a``,"
278301" all is well."
279302msgstr ""
280- "그다음 ``B`` 의 :meth:`__radd__` 메서드가 기회를 얻습니다. 이 메서드가 ``a`` 를 받을 수 있다면 모든 것이 "
281- " 문제없이 처리됩니다."
303+ "그다음 ``B`` 의 :meth:`~object. __radd__` 메서드가 기회를 얻습니다. 이 메서드가 ``a`` 를 받을 수 "
304+ "있다면 모든 것이 문제없이 처리됩니다."
282305
283306#: ../../library/numbers.rst:175
284307msgid ""
@@ -297,16 +320,15 @@ msgstr ""
297320"이 인스턴스를 처리할 수 있습니다."
298321
299322#: ../../library/numbers.rst:183
300- #, fuzzy
301323msgid ""
302324"If ``A <: Complex`` and ``B <: Real`` without sharing any other "
303325"knowledge, then the appropriate shared operation is the one involving the"
304326" built in :class:`complex`, and both :meth:`~object.__radd__` s land "
305327"there, so ``a+b == b+a``."
306328msgstr ""
307329"만약 어떤 것도 공유하지 않는 ``A <: Complex`` 와 ``B <: Real`` 라면 적절한 공유 연산(shared "
308- "operation)은 내장 :class:`complex` 클래스에 연관된 것입니다. 양쪽의 :meth:`__radd__` 메서드가 "
309- "여기에 해당하므로 ``a+b == b+a`` 가 됩니다."
330+ "operation)은 내장 :class:`complex` 클래스에 연관된 것입니다. 양쪽의 "
331+ ":meth:`~object.__radd__` 메서드가 여기에 해당하므로 ``a+b == b+a`` 가 됩니다."
310332
311333#: ../../library/numbers.rst:188
312334msgid ""
@@ -359,4 +381,41 @@ msgid ""
359381"\n"
360382"# ..."
361383msgstr ""
384+ "def _operator_fallbacks(monomorphic_operator, fallback_operator):\n"
385+ " def forward(a, b):\n"
386+ " if isinstance(b, (int, Fraction)):\n"
387+ " return monomorphic_operator(a, b)\n"
388+ " elif isinstance(b, float):\n"
389+ " return fallback_operator(float(a), b)\n"
390+ " elif isinstance(b, complex):\n"
391+ " return fallback_operator(complex(a), b)\n"
392+ " else:\n"
393+ " return NotImplemented\n"
394+ " forward.__name__ = '__' + fallback_operator.__name__ + '__'\n"
395+ " forward.__doc__ = monomorphic_operator.__doc__\n"
396+ "\n"
397+ " def reverse(b, a):\n"
398+ " if isinstance(a, Rational):\n"
399+ " # 정수를 포함합니다.\n"
400+ " return monomorphic_operator(a, b)\n"
401+ " elif isinstance(a, Real):\n"
402+ " return fallback_operator(float(a), float(b))\n"
403+ " elif isinstance(a, Complex):\n"
404+ " return fallback_operator(complex(a), complex(b))\n"
405+ " else:\n"
406+ " return NotImplemented\n"
407+ " reverse.__name__ = '__r' + fallback_operator.__name__ + '__'\n"
408+ " reverse.__doc__ = monomorphic_operator.__doc__\n"
409+ "\n"
410+ " return forward, reverse\n"
411+ "\n"
412+ "def _add(a, b):\n"
413+ " \"\"\" a + b\"\"\" \n"
414+ " return Fraction(a.numerator * b.denominator +\n"
415+ " b.numerator * a.denominator,\n"
416+ " a.denominator * b.denominator)\n"
417+ "\n"
418+ "__add__, __radd__ = _operator_fallbacks(_add, operator.add)\n"
419+ "\n"
420+ "# ..."
362421
0 commit comments