p.add_argument('-o', action='append')
for i in range(1, 4):
    p.add_argument('arg%d' % i)
args = p.parse_args('-o option1 arg1 -o option2 arg2 arg3'.split())
Processing command-line arguments in prefix notation in Python