17 questions for “Command-Line Interfaces (argparse)”

Found in 1 field. Select a question to see its full answer.

Information Technology

17 questions in 1 technology

#QuestionTechnologyTopicLevel
1How do you create a basic command-line argument parser using argparse? Python › Command-Line Interfaces (argparse)PythonCommand-Line Interfaces (argparse)Beginner
2What is the difference between a positional argument and an optional argument (flag) in argparse? Python › Command-Line Interfaces (argparse)PythonCommand-Line Interfaces (argparse)Beginner
3How do you specify a default value and a type conversion for an argument? Python › Command-Line Interfaces (argparse)PythonCommand-Line Interfaces (argparse)Intermediate
4How do you restrict an argument's accepted values using the 'choices' parameter? Python › Command-Line Interfaces (argparse)PythonCommand-Line Interfaces (argparse)Intermediate
5How do you accept a variable number of arguments for a single flag, like a list of filenames? Python › Command-Line Interfaces (argparse)PythonCommand-Line Interfaces (argparse)Intermediate
6How do you implement boolean flags using action='store_true' and action='store_false'? Python › Command-Line Interfaces (argparse)PythonCommand-Line Interfaces (argparse)Intermediate
7How do you provide a short and a long form for the same flag, like -v and --verbose? Python › Command-Line Interfaces (argparse)PythonCommand-Line Interfaces (argparse)Intermediate
8How do you implement subcommands (like 'git commit' or 'git push') using argparse's add_subparsers()? Python › Command-Line Interfaces (argparse)PythonCommand-Line Interfaces (argparse)Advanced
9How do you group related arguments visually in the generated --help output using argument groups? Python › Command-Line Interfaces (argparse)PythonCommand-Line Interfaces (argparse)Advanced
10How do you implement mutually exclusive arguments, where the user must choose EXACTLY ONE of a set of flags? Python › Command-Line Interfaces (argparse)PythonCommand-Line Interfaces (argparse)Advanced