In Perl, One can easily read in multiple key=value pair into a variable (a hash) using Getopt::Long (see here )
Basically it says
GetOptions ("define=s" => \%defines);
And on command line: <prog> --define os=linux --define vendor=redhat
I have been looking an equivalent in Python but hasn't found any so far [argparse] doesn't take in dictionary from bash shell easily see type=dict in argparse.add_argument() . Although I can work around this by reading in the arguments and programmatically create a dictionary out of it, I just wanted to know a clean and simple way to do it (like Perl has)
argparsestyle input would be more like:python stack18800328.py --os=linux --vendor=redhat. But that requires knowing the possible 'key' values ahead of time.defineas anappendargument inargparsefollowed by this one liner is the most compact way I can think of:args.define = {k:v for k,v in (a.split('=') for a in args.define)}