Home Command line arguments as variable definition in Python
 I'm trying to construct a (kind of template/wrapper) script, which is called with some undefined options > the_script.py --foo=23 --bar=42 --narf=fjoord  which then creates a variable called foo=23, bar=42, narf='fjoord' inside it. What's the way to do it? I tried with getopt, but it needs a second parameter, so I have to define which options to get and of course, I want to be able to define my variable names via command line. I tried OptionParser too, not sure how to deal with undefined options though. So is the way manually parsing the sys.argv, or is there maybe a module out there, which does exactly the same thing?