In my python script, I want to be able to use an optional input parameter only when another optional parameter has been specified. Example:
$ python
One idea would be to manually check the output of calling parser.parse_args() and raise an exception or otherwise fail if --parameter2 is used but --parameter1 isn't.
You could also try setting a custom action (scroll down a bit) to --parameter2 check if --parameter1 exists inside the namespace.
Finally, you could try using subparsers, although I don't know if it'll let you specify a value for --parameter1.