6
6
msgstr ""
7
7
"Project-Id-Version : Python 3.13\n "
8
8
"Report-Msgid-Bugs-To : \n "
9
- "POT-Creation-Date : 2024-10-09 00:13+0000 \n "
9
+ "POT-Creation-Date : 2024-12-29 18:06+0800 \n "
10
10
"PO-Revision-Date : YEAR-MO-DA HO:MI+ZONE\n "
11
11
"Last-Translator : FULL NAME <EMAIL@ADDRESS>\n "
12
12
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -16,101 +16,118 @@ msgstr ""
16
16
"Content-Type : text/plain; charset=UTF-8\n "
17
17
"Content-Transfer-Encoding : 8bit\n "
18
18
19
- #: ../../howto/argparse-optparse.rst:7
20
- msgid "Upgrading optparse code"
19
+ #: ../../howto/argparse-optparse.rst:8
20
+ #, fuzzy
21
+ msgid "Migrating ``optparse`` code to ``argparse``"
21
22
msgstr "升級 optparse 程式碼"
22
23
23
- #: ../../howto/argparse-optparse.rst:9
24
- msgid ""
25
- "Originally, the :mod:`argparse` module had attempted to maintain "
26
- "compatibility with :mod:`optparse`. However, :mod:`optparse` was difficult "
27
- "to extend transparently, particularly with the changes required to support "
28
- "``nargs=`` specifiers and better usage messages. When most everything in :"
29
- "mod:`optparse` had either been copy-pasted over or monkey-patched, it no "
30
- "longer seemed practical to try to maintain the backwards compatibility."
31
- msgstr ""
32
-
33
- #: ../../howto/argparse-optparse.rst:16
24
+ #: ../../howto/argparse-optparse.rst:10
34
25
msgid ""
35
- "The :mod:`argparse` module improves on the :mod:`optparse` module in a "
36
- "number of ways including:"
26
+ "The :mod:`argparse` module offers several higher level features not natively "
27
+ "provided by the :mod:`optparse` module, including:"
37
28
msgstr ""
38
29
39
- #: ../../howto/argparse-optparse.rst:19
30
+ #: ../../howto/argparse-optparse.rst:13
40
31
msgid "Handling positional arguments."
41
32
msgstr ""
42
33
43
- #: ../../howto/argparse-optparse.rst:20
34
+ #: ../../howto/argparse-optparse.rst:14
44
35
msgid "Supporting subcommands."
45
36
msgstr ""
46
37
47
- #: ../../howto/argparse-optparse.rst:21
38
+ #: ../../howto/argparse-optparse.rst:15
48
39
msgid "Allowing alternative option prefixes like ``+`` and ``/``."
49
40
msgstr ""
50
41
51
- #: ../../howto/argparse-optparse.rst:22
42
+ #: ../../howto/argparse-optparse.rst:16
52
43
msgid "Handling zero-or-more and one-or-more style arguments."
53
44
msgstr ""
54
45
55
- #: ../../howto/argparse-optparse.rst:23
46
+ #: ../../howto/argparse-optparse.rst:17
56
47
msgid "Producing more informative usage messages."
57
48
msgstr ""
58
49
59
- #: ../../howto/argparse-optparse.rst:24
50
+ #: ../../howto/argparse-optparse.rst:18
60
51
msgid "Providing a much simpler interface for custom ``type`` and ``action``."
61
52
msgstr ""
62
53
63
- #: ../../howto/argparse-optparse.rst:26
64
- msgid "A partial upgrade path from :mod:`optparse` to :mod:`argparse`:"
54
+ #: ../../howto/argparse-optparse.rst:20
55
+ msgid ""
56
+ "Originally, the :mod:`argparse` module attempted to maintain compatibility "
57
+ "with :mod:`optparse`. However, the fundamental design differences between "
58
+ "supporting declarative command line option processing (while leaving "
59
+ "positional argument processing to application code), and supporting both "
60
+ "named options and positional arguments in the declarative interface mean "
61
+ "that the API has diverged from that of ``optparse`` over time."
62
+ msgstr ""
63
+
64
+ #: ../../howto/argparse-optparse.rst:27
65
+ msgid ""
66
+ "As described in :ref:`choosing-an-argument-parser`, applications that are "
67
+ "currently using :mod:`optparse` and are happy with the way it works can just "
68
+ "continue to use ``optparse``."
69
+ msgstr ""
70
+
71
+ #: ../../howto/argparse-optparse.rst:31
72
+ msgid ""
73
+ "Application developers that are considering migrating should also review the "
74
+ "list of intrinsic behavioural differences described in that section before "
75
+ "deciding whether or not migration is desirable."
76
+ msgstr ""
77
+
78
+ #: ../../howto/argparse-optparse.rst:35
79
+ msgid ""
80
+ "For applications that do choose to migrate from :mod:`optparse` to :mod:"
81
+ "`argparse`, the following suggestions should be helpful:"
65
82
msgstr ""
66
83
67
- #: ../../howto/argparse-optparse.rst:28
84
+ #: ../../howto/argparse-optparse.rst:38
68
85
msgid ""
69
86
"Replace all :meth:`optparse.OptionParser.add_option` calls with :meth:"
70
87
"`ArgumentParser.add_argument` calls."
71
88
msgstr ""
72
89
73
- #: ../../howto/argparse-optparse.rst:31
90
+ #: ../../howto/argparse-optparse.rst:41
74
91
msgid ""
75
92
"Replace ``(options, args) = parser.parse_args()`` with ``args = parser."
76
93
"parse_args()`` and add additional :meth:`ArgumentParser.add_argument` calls "
77
94
"for the positional arguments. Keep in mind that what was previously called "
78
95
"``options``, now in the :mod:`argparse` context is called ``args``."
79
96
msgstr ""
80
97
81
- #: ../../howto/argparse-optparse.rst:36
98
+ #: ../../howto/argparse-optparse.rst:46
82
99
msgid ""
83
100
"Replace :meth:`optparse.OptionParser.disable_interspersed_args` by using :"
84
101
"meth:`~ArgumentParser.parse_intermixed_args` instead of :meth:"
85
102
"`~ArgumentParser.parse_args`."
86
103
msgstr ""
87
104
88
- #: ../../howto/argparse-optparse.rst:40
105
+ #: ../../howto/argparse-optparse.rst:50
89
106
msgid ""
90
107
"Replace callback actions and the ``callback_*`` keyword arguments with "
91
108
"``type`` or ``action`` arguments."
92
109
msgstr ""
93
110
94
- #: ../../howto/argparse-optparse.rst:43
111
+ #: ../../howto/argparse-optparse.rst:53
95
112
msgid ""
96
113
"Replace string names for ``type`` keyword arguments with the corresponding "
97
114
"type objects (e.g. int, float, complex, etc)."
98
115
msgstr ""
99
116
100
- #: ../../howto/argparse-optparse.rst:46
117
+ #: ../../howto/argparse-optparse.rst:56
101
118
msgid ""
102
119
"Replace :class:`optparse.Values` with :class:`Namespace` and :exc:`optparse."
103
120
"OptionError` and :exc:`optparse.OptionValueError` with :exc:`ArgumentError`."
104
121
msgstr ""
105
122
106
- #: ../../howto/argparse-optparse.rst:50
123
+ #: ../../howto/argparse-optparse.rst:60
107
124
msgid ""
108
125
"Replace strings with implicit arguments such as ``%default`` or ``%prog`` "
109
126
"with the standard Python syntax to use dictionaries to format strings, that "
110
127
"is, ``%(default)s`` and ``%(prog)s``."
111
128
msgstr ""
112
129
113
- #: ../../howto/argparse-optparse.rst:54
130
+ #: ../../howto/argparse-optparse.rst:64
114
131
msgid ""
115
132
"Replace the OptionParser constructor ``version`` argument with a call to "
116
133
"``parser.add_argument('--version', action='version', version='<the "
0 commit comments