Skip to content
Advertisement

Is it possible to use argparse to capture an arbitrary set of optional arguments?

Is it possible to use argparse to capture an arbitrary set of optional arguments?

For example both the following should be accepted as inputs:

JavaScript

a priori I don’t know what optional arguments would be specified receive but would handle them accordingly.

Advertisement

Answer

This is kind of a hackish way, but it works well:

Check, which arguments are not added and add them

JavaScript

For example:

JavaScript

Then the result would be

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement