Check out the argparse module (or optparse for older Python versions). Note that argparse/optparse are newer, better replacements for getopt, so if you're new to this they're the recommended option. From the getopt docs: Note The getopt module is a parser for command line options whose API is designed to be familiar to users of the C getopt() function.
Users who are unfamiliar with the C getopt() function or who would like to write less code and get better help and error messages should consider using the argparse module instead.
And by "older Python versions", he means every version that was released more than 8 days ago. – ʇsәɹoɈ Jul 13 '10 at 6:21 @Forest - shhhh, we're in the future now! ;) – tzaman Jul 13 '10 at 6:36.
Python has argument processing built in, with the getopt module. It can handle long and short forms of arguments as well as "naked" and parameterised versions (--help versus --num=7). For your specific use cases (with a little more), you'd probably be looking at something like: opts,args = getopt.
Getopt(argv,"b:vVh","block=", "verbose", "very-verbose", "help") I'm not sure off the top of my head if it allows multi-character single-hyphen variants like -vv. I'd just use -v and -V myself to make my life easier.
A better option than that link is the modules OptParse or GetOpt, and depending on which version of python you're using, the newest ones..2.7, and 3.1.2, have an even newer module built in. The documentation on the official python. Org reference has a very informative set of documentation and examples for those modules.
If you go to python. Org and just do a quick search for OptParse or GetOpt, you'll have everything you need.
Optfunc is an interesting little module. It's great if you want to quickly write a little script. For larger things I would go with argparse as others wrote.
There might be a better way but I would just uses sys. Argv and put in conditionals wherever needed i.e. If '--v' or '--vv' in sys.
Argv : print 'verbose message.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.