I am not sure what optparse‘s metavar parameter is used for. I see it is used all around, but I can’t see its use.
Can someone make it clear to me? Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As @Guillaume says, it’s used for generating help. If you want to have an option that takes an argument, such as a filename, you can add the
metavarparameter to theadd_optioncall so your preferred argument name/descriptor is output in the help message. From the current module documentation:would produce help like this:
The ‘FILE’ after the ‘-f’ and the ‘–filename’ comes from the metavar.