@@ -121,18 +121,17 @@ msgstr ""
121121"๋
ธ์ถํฉ๋๋ค."
122122
123123#: ../../library/weakref.rst:68
124- #, fuzzy
125124msgid ""
126125"Not all objects can be weakly referenced. Objects which support weak "
127126"references include class instances, functions written in Python (but not "
128127"in C), instance methods, sets, frozensets, some :term:`file objects <file"
129128" object>`, :term:`generators <generator>`, type objects, sockets, arrays,"
130129" deques, regular expression pattern objects, and code objects."
131130msgstr ""
132- "๋ชจ๋ ๊ฐ์ฒด๋ฅผ ์ฝํ๊ฒ ์ฐธ์กฐํ ์ ์๋ ๊ฒ์ ์๋๋๋ค; ๊ฐ๋ฅํ ๊ฐ์ฒด์๋ ํด๋์ค ์ธ์คํด์ค, ํ์ด์ฌ์ผ๋ก ์์ฑ๋ ํจ์ (C๋ก ์์ฑ๋ ํจ์๋ "
133- "์๋๋๋ค), ์ธ์คํด์ค ๋ฉ์๋, ์งํฉ, ๋ถ๋ณ ์งํฉ(frozenset), ์ผ๋ถ :term:`ํ์ผ ๊ฐ์ฒด <file object>`, "
134- ":term:`์ ๋๋ ์ดํฐ <generator>`, ํ ๊ฐ์ฒด, ์์ผ, ๋ฐฐ์ด, ๋ฐํฌ(deque), ์ ๊ท์ ํจํด ๊ฐ์ฒด ๋ฐ ์ฝ๋ ๊ฐ์ฒด๊ฐ "
135- "ํฌํจ๋ฉ๋๋ค."
131+ "๋ชจ๋ ๊ฐ์ฒด๋ฅผ ์ฝํ๊ฒ ์ฐธ์กฐํ ์ ์๋ ๊ฒ์ ์๋๋๋ค. ์ฝํ ์ฐธ์กฐ๋ฅผ ์ง์ํ๋ ๊ฐ์ฒด์๋ ํด๋์ค ์ธ์คํด์ค, ํ์ด์ฌ์ผ๋ก ์์ฑ๋ ํจ์ (C๋ก "
132+ "์์ฑ๋ ํจ์๋ ์๋๋๋ค), ์ธ์คํด์ค ๋ฉ์๋, ์งํฉ, ๋ถ๋ณ ์งํฉ(frozenset), ์ผ๋ถ :term:`ํ์ผ ๊ฐ์ฒด <file "
133+ "object>`, :term:`์ ๋๋ ์ดํฐ <generator>`, ํ ๊ฐ์ฒด, ์์ผ, ๋ฐฐ์ด, ๋ฐํฌ(deque), ์ ๊ท์ ํจํด ๊ฐ์ฒด ๋ฐ"
134+ " ์ฝ๋ ๊ฐ์ฒด๊ฐ ํฌํจ๋ฉ๋๋ค."
136135
137136#: ../../library/weakref.rst:74
138137msgid "Added support for thread.lock, threading.Lock, and code objects."
@@ -154,6 +153,10 @@ msgid ""
154153"\n"
155154"obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable"
156155msgstr ""
156+ "class Dict(dict):\n"
157+ " pass\n"
158+ "\n"
159+ "obj = Dict(red=1, green=2, blue=3) # ์ด ๊ฐ์ฒด๋ ์ฝํ ์ฐธ์กฐํ ์ ์์ต๋๋ค"
157160
158161#: ../../library/weakref.rst:87
159162msgid ""
@@ -201,14 +204,13 @@ msgstr ""
201204"์ค๋์ ์ ๋ฑ๋ก๋ ์ฝ๋ฐฑ ์์ผ๋ก ํธ์ถ๋ฉ๋๋ค."
202205
203206#: ../../library/weakref.rst:112
204- #, fuzzy
205207msgid ""
206208"Exceptions raised by the callback will be noted on the standard error "
207209"output, but cannot be propagated; they are handled in exactly the same "
208210"way as exceptions raised from an object's :meth:`~object.__del__` method."
209211msgstr ""
210- "์ฝ๋ฐฑ์ ์ํด ๋ฐ์ํ ์์ธ๋ ํ์ค ์๋ฌ ์ถ๋ ฅ์ ํ์๋์ง๋ง, ์ ํ๋ ์๋ ์์ต๋๋ค; ๊ฐ์ฒด์ :meth:`__del__` ๋ฉ์๋์์ "
211- "๋ฐ์ํ ์์ธ์ ์ ํํ ๊ฐ์ ๋ฐฉ์์ผ๋ก ์ฒ๋ฆฌ๋ฉ๋๋ค."
212+ "์ฝ๋ฐฑ์ ์ํด ๋ฐ์ํ ์์ธ๋ ํ์ค ์๋ฌ ์ถ๋ ฅ์ ํ์๋์ง๋ง, ์ ํ๋ ์๋ ์์ต๋๋ค; ๊ฐ์ฒด์ :meth:`~object. __del__` "
213+ "๋ฉ์๋์์ ๋ฐ์ํ ์์ธ์ ์ ํํ ๊ฐ์ ๋ฐฉ์์ผ๋ก ์ฒ๋ฆฌ๋ฉ๋๋ค."
212214
213215#: ../../library/weakref.rst:116
214216msgid ""
@@ -251,7 +253,6 @@ msgid "Added the :attr:`__callback__` attribute."
251253msgstr ":attr:`__callback__` ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ ์ถ๊ฐํ์ต๋๋ค."
252254
253255#: ../../library/weakref.rst:140
254- #, fuzzy
255256msgid ""
256257"Return a proxy to *object* which uses a weak reference. This supports "
257258"use of the proxy in most contexts instead of requiring the explicit "
@@ -323,6 +324,13 @@ msgid ""
323324">>> d[k2] = 2 # d = {k1: 2}\n"
324325">>> del k1 # d = {}"
325326msgstr ""
327+ ">>> class T(str): pass\n"
328+ "...\n"
329+ ">>> k1, k2 = T(), T()\n"
330+ ">>> d = weakref.WeakKeyDictionary()\n"
331+ ">>> d[k1] = 1 # d = {k1: 1}\n"
332+ ">>> d[k2] = 2 # d = {k1: 2}\n"
333+ ">>> del k1 # d = {}"
326334
327335#: ../../library/weakref.rst:188
328336msgid "A workaround would be to remove the key prior to reassignment::"
@@ -340,6 +348,14 @@ msgid ""
340348">>> d[k2] = 2 # d = {k2: 2}\n"
341349">>> del k1 # d = {k2: 2}"
342350msgstr ""
351+ ">>> class T(str): pass\n"
352+ "...\n"
353+ ">>> k1, k2 = T(), T()\n"
354+ ">>> d = weakref.WeakKeyDictionary()\n"
355+ ">>> d[k1] = 1 # d = {k1: 1}\n"
356+ ">>> del d[k1]\n"
357+ ">>> d[k2] = 2 # d = {k2: 2}\n"
358+ ">>> del k1 # d = {k2: 2}"
343359
344360#: ../../library/weakref.rst:199 ../../library/weakref.rst:220
345361msgid "Added support for ``|`` and ``|=`` operators, as specified in :pep:`584`."
@@ -369,13 +385,12 @@ msgid ""
369385msgstr "๊ฐ์ ์ฝํ๊ฒ ์ฐธ์กฐํ๋ ๋งคํ ํด๋์ค. ๊ฐ์ ๋ํ ๊ฐํ ์ฐธ์กฐ๊ฐ ๋๋ ์กด์ฌํ์ง ์์ ๋ ๋์
๋๋ฆฌ์ ํญ๋ชฉ์ด ์ญ์ ๋ฉ๋๋ค."
370386
371387#: ../../library/weakref.rst:223
372- #, fuzzy
373388msgid ""
374389":class:`WeakValueDictionary` objects have an additional method that has "
375390"the same issues as the :meth:`WeakKeyDictionary.keyrefs` method."
376391msgstr ""
377- ":class:`WeakValueDictionary` ๊ฐ์ฒด์๋ :class:`WeakKeyDictionary` ๊ฐ์ฒด์ "
378- ":meth:`keyrefs` ๋ฉ์๋์ ๊ฐ์ ๋ฌธ์ ๊ฐ ์๋ ์ถ๊ฐ ๋ฉ์๋๊ฐ ์์ต๋๋ค."
392+ ":class:`WeakValueDictionary` ๊ฐ์ฒด์๋ :class:`WeakKeyDictionary.keyrefs` ๋ฉ์๋์ "
393+ " ๊ฐ์ ๋ฌธ์ ๊ฐ ์๋ ์ถ๊ฐ ๋ฉ์๋๊ฐ ์์ต๋๋ค."
379394
380395#: ../../library/weakref.rst:229
381396msgid "Return an iterable of the weak references to the values."
@@ -419,6 +434,23 @@ msgid ""
419434">>> r()\n"
420435">>>"
421436msgstr ""
437+ ">>> class C:\n"
438+ "... def method(self):\n"
439+ "... print(\" method called!\" )\n"
440+ "...\n"
441+ ">>> c = C()\n"
442+ ">>> r = weakref.ref(c.method)\n"
443+ ">>> r()\n"
444+ ">>> r = weakref.WeakMethod(c.method)\n"
445+ ">>> r()\n"
446+ "<bound method C.method of <__main__.C object at 0x7fc859830220>>\n"
447+ ">>> r()()\n"
448+ "method called!\n"
449+ ">>> del c\n"
450+ ">>> gc.collect()\n"
451+ "0\n"
452+ ">>> r()\n"
453+ ">>>"
422454
423455#: ../../library/weakref.rst:264
424456msgid ""
@@ -448,15 +480,14 @@ msgstr ""
448480":const:`None`\\ ์ด ๋ฐํ๋ฉ๋๋ค."
449481
450482#: ../../library/weakref.rst:280
451- #, fuzzy
452483msgid ""
453484"Exceptions raised by finalizer callbacks during garbage collection will "
454485"be shown on the standard error output, but cannot be propagated. They "
455486"are handled in the same way as exceptions raised from an object's "
456487":meth:`~object.__del__` method or a weak reference's callback."
457488msgstr ""
458489"๊ฐ๋น์ง ์๊ฑฐ ์ค์ ํ์ด๋๋ผ์ด์ ์ฝ๋ฐฑ์์ ๋ฐ์ํ ์์ธ๋ ํ์ค ์๋ฌ ์ถ๋ ฅ์ ํ์๋์ง๋ง, ์ ํํ ์๋ ์์ต๋๋ค. ๊ฐ์ฒด์ "
459- ":meth:`__del__` ๋ฉ์๋๋ ์ฝํ ์ฐธ์กฐ์ ์ฝ๋ฐฑ์์ ๋ฐ์ํ๋ ์์ธ์ ๊ฐ์ ๋ฐฉ์์ผ๋ก ์ฒ๋ฆฌ๋ฉ๋๋ค."
490+ ":meth:`~object. __del__` ๋ฉ์๋๋ ์ฝํ ์ฐธ์กฐ์ ์ฝ๋ฐฑ์์ ๋ฐ์ํ๋ ์์ธ์ ๊ฐ์ ๋ฐฉ์์ผ๋ก ์ฒ๋ฆฌ๋ฉ๋๋ค."
460491
461492#: ../../library/weakref.rst:286
462493msgid ""
@@ -595,6 +626,14 @@ msgid ""
595626" print(\" Object is still live!\" )\n"
596627" o.do_something_useful()"
597628msgstr ""
629+ "# r์ ์ฝํ ์ฐธ์กฐ ๊ฐ์ฒด์
๋๋ค\n"
630+ "o = r()\n"
631+ "if o is None:\n"
632+ " # ์ฐธ์กฐ๋์์ด ๊ฐ๋น์ง ์๊ฑฐ๋์์ต๋๋ค\n"
633+ " print(\" Object has been deallocated; can't frobnicate.\" )\n"
634+ "else:\n"
635+ " print(\" Object is still live!\" )\n"
636+ " o.do_something_useful()"
598637
599638#: ../../library/weakref.rst:400
600639msgid ""
@@ -652,6 +691,23 @@ msgid ""
652691" ob = (ob, self.__counter)\n"
653692" return ob"
654693msgstr ""
694+ "import weakref\n"
695+ "\n"
696+ "class ExtendedRef(weakref.ref):\n"
697+ " def __init__(self, ob, callback=None, /, **annotations):\n"
698+ " super().__init__(ob, callback)\n"
699+ " self.__counter = 0\n"
700+ " for k, v in annotations.items():\n"
701+ " setattr(self, k, v)\n"
702+ "\n"
703+ " def __call__(self):\n"
704+ " \"\"\" ์ฐธ์กฐ๋์๊ณผ ์ฐธ์กฐ๊ฐ ํธ์ถ๋ ํ์๋ฅผ ํฌํจํ๋ ์์ ๋ฐํํฉ๋๋ค.\n"
705+ " \"\"\" \n"
706+ " ob = super().__call__()\n"
707+ " if ob is not None:\n"
708+ " self.__counter += 1\n"
709+ " ob = (ob, self.__counter)\n"
710+ " return ob"
655711
656712#: ../../library/weakref.rst:438
657713msgid "Example"
@@ -681,6 +737,17 @@ msgid ""
681737"def id2obj(oid):\n"
682738" return _id2obj_dict[oid]"
683739msgstr ""
740+ "import weakref\n"
741+ "\n"
742+ "_id2obj_dict = weakref.WeakValueDictionary()\n"
743+ "\n"
744+ "def remember(obj):\n"
745+ " oid = id(obj)\n"
746+ " _id2obj_dict[oid] = obj\n"
747+ " return oid\n"
748+ "\n"
749+ "def id2obj(oid):\n"
750+ " return _id2obj_dict[oid]"
684751
685752#: ../../library/weakref.rst:465
686753msgid "Finalizer Objects"
@@ -727,11 +794,15 @@ msgid ""
727794">>> exit()\n"
728795"obj dead or exiting"
729796msgstr ""
797+ ">>> obj = Object()\n"
798+ ">>> weakref.finalize(obj, print, \" obj dead or exiting\" )\n"
799+ "<finalize object at ...; for 'Object' at ...>\n"
800+ ">>> exit()\n"
801+ "obj dead or exiting"
730802
731803#: ../../library/weakref.rst:526
732- #, fuzzy
733804msgid "Comparing finalizers with :meth:`~object.__del__` methods"
734- msgstr "ํ์ด๋๋ผ์ด์ ์ :meth:`__del__` ๋ฉ์๋์ ๋น๊ต"
805+ msgstr "ํ์ด๋๋ผ์ด์ ์ :meth:`~object. __del__` ๋ฉ์๋์ ๋น๊ต"
735806
736807#: ../../library/weakref.rst:528
737808msgid ""
@@ -747,20 +818,18 @@ msgid "the object is garbage collected,"
747818msgstr "๊ฐ์ฒด๊ฐ ๊ฐ๋น์ง ์๊ฑฐ๋ฉ๋๋ค,"
748819
749820#: ../../library/weakref.rst:533
750- #, fuzzy
751821msgid "the object's :meth:`!remove` method is called, or"
752- msgstr "๊ฐ์ฒด์ :meth:`remove` ๋ฉ์๋๊ฐ ํธ์ถ๋ฉ๋๋ค, ๋๋"
822+ msgstr "๊ฐ์ฒด์ :meth:`! remove` ๋ฉ์๋๊ฐ ํธ์ถ๋ฉ๋๋ค, ๋๋"
753823
754824#: ../../library/weakref.rst:534
755825msgid "the program exits."
756826msgstr "ํ๋ก๊ทธ๋จ์ด ์ข
๋ฃํฉ๋๋ค."
757827
758828#: ../../library/weakref.rst:536
759- #, fuzzy
760829msgid ""
761830"We might try to implement the class using a :meth:`~object.__del__` "
762831"method as follows::"
763- msgstr "๋ค์๊ณผ ๊ฐ์ด :meth:`__del__` ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ฌ ํด๋์ค๋ฅผ ๊ตฌํํ๋ ค๊ณ ์๋ํ ์ ์์ต๋๋ค::"
832+ msgstr "๋ค์๊ณผ ๊ฐ์ด :meth:`~object. __del__` ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ฌ ํด๋์ค๋ฅผ ๊ตฌํํ๋ ค๊ณ ์๋ํ ์ ์์ต๋๋ค::"
764833
765834#: ../../library/weakref.rst:539
766835msgid ""
@@ -780,28 +849,41 @@ msgid ""
780849" def __del__(self):\n"
781850" self.remove()"
782851msgstr ""
852+ "class TempDir:\n"
853+ " def __init__(self):\n"
854+ " self.name = tempfile.mkdtemp()\n"
855+ "\n"
856+ " def remove(self):\n"
857+ " if self.name is not None:\n"
858+ " shutil.rmtree(self.name)\n"
859+ " self.name = None\n"
860+ "\n"
861+ " @property\n"
862+ " def removed(self):\n"
863+ " return self.name is None\n"
864+ "\n"
865+ " def __del__(self):\n"
866+ " self.remove()"
783867
784868#: ../../library/weakref.rst:555
785- #, fuzzy
786869msgid ""
787870"Starting with Python 3.4, :meth:`~object.__del__` methods no longer "
788871"prevent reference cycles from being garbage collected, and module globals"
789872" are no longer forced to :const:`None` during :term:`interpreter "
790873"shutdown`. So this code should work without any issues on CPython."
791874msgstr ""
792- "ํ์ด์ฌ 3.4๋ถํฐ, :meth:`__del__` ๋ฉ์๋๋ ๋๋ ์ฐธ์กฐ ์ํ์ด ๊ฐ๋น์ง ์๊ฑฐ๋๋ ๊ฒ์ ๋ง์ง ์์ผ๋ฉฐ, "
875+ "ํ์ด์ฌ 3.4๋ถํฐ, :meth:`~object. __del__` ๋ฉ์๋๋ ๋๋ ์ฐธ์กฐ ์ํ์ด ๊ฐ๋น์ง ์๊ฑฐ๋๋ ๊ฒ์ ๋ง์ง ์์ผ๋ฉฐ, "
793876":term:`์ธํฐํ๋ฆฌํฐ ์ข
๋ฃ <interpreter shutdown>` ์ค์ ๋ชจ๋ ์ ์ญ์ด ๋๋ :const:`None`\\ ์ผ๋ก "
794877"๊ฐ์ ๋์ง ์์ต๋๋ค. ๋ฐ๋ผ์ ์ด ์ฝ๋๋ CPython์์ ์๋ฌด๋ฐ ๋ฌธ์ ์์ด ์๋ํด์ผ ํฉ๋๋ค."
795878
796879#: ../../library/weakref.rst:560
797- #, fuzzy
798880msgid ""
799881"However, handling of :meth:`~object.__del__` methods is notoriously "
800882"implementation specific, since it depends on internal details of the "
801883"interpreter's garbage collector implementation."
802884msgstr ""
803- "๊ทธ๋ฌ๋, :meth:`__del__` ๋ฉ์๋์ ์ฒ๋ฆฌ๋ ์ธํฐํ๋ฆฌํฐ์ ๊ฐ๋น์ง ์๊ฑฐ๊ธฐ ๊ตฌํ์ ๋ํ ๋ด๋ถ ์ธ๋ถ ์ฌํญ์ ์์กดํ๊ธฐ ๋๋ฌธ์ "
804- "๊ตฌํ์ ๋ฐ๋ผ ๋ค๋ฅด๊ธฐ๋ก ์
๋ช
๋์ต๋๋ค."
885+ "๊ทธ๋ฌ๋, :meth:`~object. __del__` ๋ฉ์๋์ ์ฒ๋ฆฌ๋ ์ธํฐํ๋ฆฌํฐ์ ๊ฐ๋น์ง ์๊ฑฐ๊ธฐ ๊ตฌํ์ ๋ํ ๋ด๋ถ ์ธ๋ถ ์ฌํญ์ "
886+ "์์กดํ๊ธฐ ๋๋ฌธ์ ๊ตฌํ์ ๋ฐ๋ผ ๋ค๋ฅด๊ธฐ๋ก ์
๋ช
๋์ต๋๋ค."
805887
806888#: ../../library/weakref.rst:564
807889msgid ""
@@ -825,6 +907,18 @@ msgid ""
825907" def removed(self):\n"
826908" return not self._finalizer.alive"
827909msgstr ""
910+ "class TempDir:\n"
911+ " def __init__(self):\n"
912+ " self.name = tempfile.mkdtemp()\n"
913+ " self._finalizer = weakref.finalize(self, shutil.rmtree, "
914+ "self.name)\n"
915+ "\n"
916+ " def remove(self):\n"
917+ " self._finalizer()\n"
918+ "\n"
919+ " @property\n"
920+ " def removed(self):\n"
921+ " return not self._finalizer.alive"
828922
829923#: ../../library/weakref.rst:580
830924msgid ""
@@ -851,6 +945,10 @@ msgid ""
851945" # implicit reference to the module globals from the function body\n"
852946"weakref.finalize(sys.modules[__name__], unloading_module)"
853947msgstr ""
948+ "import weakref, sys\n"
949+ "def unloading_module():\n"
950+ " # ํจ์ ๋ฐ๋์์ ๋ชจ๋ ์ ์ญ์ผ๋ก์ ๋ฌต์์ ์ฐธ์กฐ\n"
951+ "weakref.finalize(sys.modules[__name__], unloading_module)"
854952
855953#: ../../library/weakref.rst:596
856954msgid ""
0 commit comments