I am writing a number of webservice client scripts all of which will use the same underlying common argparse script to break down the command line parameters into arguments.
I'm hitting a problem where I have to provide a group of arguments several times where I'd like them to be parsed into lists (one for each argument group).

For example, one of my services assigns role assignments for a user. So I'd like my script will accept something like the following.

script.py ... --role-assignment USER1 --role-assignment-type DEVELOPER --type USER --role-assignment USER2 --role-assignment-type DEVELOPER --type USER --role-assignment USER3 --role-assignment ADMIN --type USER ...

So here above I'm passing 3 sets or groups of arguments to my script that sets the role assignments for a user. These are --role-assignment --role-assignment-type and --type.

I know that I can do the following.

parser = argparse.ArgumentParser()
parser.add_argument('--role-assignment', nargs=3, action='append')
args = parser.parse_args()
..

The above would mean that I would have to provide my arguments in the following way.
script.py ... --role-assignment USER1 DEVELOPER USER --role-assignment USER2 DEVELOPER USER --role-assignment USER3 ADMIN USER ...

This works in a way and does give me the following which is close to what I want (but not exactly).
Namespace(role_assignment=[['USER1', 'DEVELOPER', 'USER'], ['USER2', 'DEVELOPER', 'USER'], ['USER3', 'ADMIN', 'USER']])

The positional parameters however leave room for error for the user as they can switch the order of their positions by mistake when providing the on the command line. Ideally, what I'd really like to do is pass on the command as follows (like I mentioned earlier).

script.py ... --role-assignment USER1 --role-assignment-type DEVELOPER --type USER --role-assignment USER2 --role-assignment-type DEVELOPER --type USER --role-assignment USER3 --role-assignment ADMIN --type USER ...

And I'd like the above to be parsed in the following way.

Namespace([role_assignment='USER1', role_assignment_type='DEVELOPER', type='USER'], [role_assignment='USER2', role_assignment_type='DEVELOPER', type='USER'], [role_assignment='USER3', role_assignment_type='ADMIN', type='USER'])

Is there a way I can get the above end result? I've looked over in the docs and all over but haven't found an easy answer to what I'm looking for. Thanks much in advance!