@@ -14,7 +14,7 @@ msgid ""
14
14
msgstr ""
15
15
"Project-Id-Version : Python 3.13\n "
16
16
"Report-Msgid-Bugs-To : \n "
17
- "POT-Creation-Date : 2024-10-11 14:17+0000\n "
17
+ "POT-Creation-Date : 2024-10-18 14:17+0000\n "
18
18
"PO-Revision-Date : 2021-06-28 00:52+0000\n "
19
19
"Last-Translator : Arihiro TAKASE, 2024\n "
20
20
"Language-Team : Japanese (https://app.transifex.com/python-doc/teams/5390/ "
@@ -962,6 +962,7 @@ msgid ""
962
962
msgstr ""
963
963
964
964
#: ../../howto/argparse.rst:618 ../../howto/argparse.rst:656
965
+ #: ../../howto/argparse.rst:872
965
966
msgid "Output:"
966
967
msgstr "出力:"
967
968
@@ -1272,10 +1273,82 @@ msgstr ""
1272
1273
"ます。"
1273
1274
1274
1275
#: ../../howto/argparse.rst:845
1276
+ msgid "Custom type converters"
1277
+ msgstr ""
1278
+
1279
+ #: ../../howto/argparse.rst:847
1280
+ msgid ""
1281
+ "The :mod:`argparse` module allows you to specify custom type converters for "
1282
+ "your command-line arguments. This allows you to modify user input before "
1283
+ "it's stored in the :class:`argparse.Namespace`. This can be useful when you "
1284
+ "need to pre-process the input before it is used in your program."
1285
+ msgstr ""
1286
+
1287
+ #: ../../howto/argparse.rst:852
1288
+ msgid ""
1289
+ "When using a custom type converter, you can use any callable that takes a "
1290
+ "single string argument (the argument value) and returns the converted value. "
1291
+ "However, if you need to handle more complex scenarios, you can use a custom "
1292
+ "action class with the **action** parameter instead."
1293
+ msgstr ""
1294
+
1295
+ #: ../../howto/argparse.rst:857
1296
+ msgid ""
1297
+ "For example, let's say you want to handle arguments with different prefixes "
1298
+ "and process them accordingly::"
1299
+ msgstr ""
1300
+
1301
+ #: ../../howto/argparse.rst:860
1302
+ msgid ""
1303
+ "import argparse\n"
1304
+ "\n"
1305
+ "parser = argparse.ArgumentParser(prefix_chars='-+')\n"
1306
+ "\n"
1307
+ "parser.add_argument('-a', metavar='<value>', action='append',\n"
1308
+ " type=lambda x: ('-', x))\n"
1309
+ "parser.add_argument('+a', metavar='<value>', action='append',\n"
1310
+ " type=lambda x: ('+', x))\n"
1311
+ "\n"
1312
+ "args = parser.parse_args()\n"
1313
+ "print(args)"
1314
+ msgstr ""
1315
+
1316
+ #: ../../howto/argparse.rst:874
1317
+ msgid ""
1318
+ "$ python prog.py -a value1 +a value2\n"
1319
+ "Namespace(a=[('-', 'value1'), ('+', 'value2')])"
1320
+ msgstr ""
1321
+
1322
+ #: ../../howto/argparse.rst:879
1323
+ msgid "In this example, we:"
1324
+ msgstr ""
1325
+
1326
+ #: ../../howto/argparse.rst:881
1327
+ msgid ""
1328
+ "Created a parser with custom prefix characters using the ``prefix_chars`` "
1329
+ "parameter."
1330
+ msgstr ""
1331
+
1332
+ #: ../../howto/argparse.rst:884
1333
+ msgid ""
1334
+ "Defined two arguments, ``-a`` and ``+a``, which used the ``type`` parameter "
1335
+ "to create custom type converters to store the value in a tuple with the "
1336
+ "prefix."
1337
+ msgstr ""
1338
+
1339
+ #: ../../howto/argparse.rst:887
1340
+ msgid ""
1341
+ "Without the custom type converters, the arguments would have treated the ``-"
1342
+ "a`` and ``+a`` as the same argument, which would have been undesirable. By "
1343
+ "using custom type converters, we were able to differentiate between the two "
1344
+ "arguments."
1345
+ msgstr ""
1346
+
1347
+ #: ../../howto/argparse.rst:892
1275
1348
msgid "Conclusion"
1276
1349
msgstr "結び"
1277
1350
1278
- #: ../../howto/argparse.rst:847
1351
+ #: ../../howto/argparse.rst:894
1279
1352
msgid ""
1280
1353
"The :mod:`argparse` module offers a lot more than shown here. Its docs are "
1281
1354
"quite detailed and thorough, and full of examples. Having gone through this "
0 commit comments