Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c2a7fd6 commit e15cb61Copy full SHA for e15cb61
1 file changed
Doc/library/argparse.rst
@@ -1425,6 +1425,21 @@ be achieved by specifying the ``namespace=`` keyword argument::
1425
'BAR'
1426
1427
1428
+Converting the namespace to a dict
1429
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1430
+
1431
+It's possible to convert a namespace to a :class:`dict` by using the built-in
1432
+function :func:`vars` in this fashion::
1433
1434
+ args = parser.parse_args()
1435
+ argdict = vars(args)
1436
1437
+This makes it easy to introspect the namespace or to pass the command-line
1438
+arguments to a function taking a bunch of keyword arguments::
1439
1440
+ somefunction(**vars(parser.parse_args()))
1441
1442
1443
Other utilities
1444
---------------
1445
0 commit comments