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)