[Tutor] File-Fetcher (cmdline-parser)

Christopher Emery cpe.list at gmail.com
Fri Mar 15 18:45:13 CET 2013


Hello Peter,

First let me say thanks for your feedback, please see comments /
question below, yours starting with PO and mine starting with CE.

PO: dest determines the attribute name under which the option is
stored. I rarely set it explicitly; instead I provide a --long-option:
CE: Is there a advantage over on or the other?

CE: Because there are options that can be added to each .add_argument
such as help=, action= is it a good idea to set each one of them even
if the default behavior is what you want?  I thinking future proofing
wise.
PO: To my eyes this is just noise.
CE: I would agree, to me less the better as long as it can be
understood and your not going to break something in the near future
that will change.

CE: At the end I use a print() to see if all is being passed or not
being passed through the cmdline, my question for you is if I want to
access the varibles that are passed through the return args, do I just
take the function like this:
outside_of_functions_var = cmdline_parser()
Does this make outside_of_functions_var a dict or list or other?
PO: Neither a dict nor a list, it is an argparse.Namespace object. You
can access commandline options as its attributes:
CE: Okay, so when I use print(args.file_list) or better yet if I take
list = args.file_list does it stay a Namespace object or does it
change?  if it stays the same how do I access the list of files inside
it?

Thank you ahead of time for your assistance in helping me to learn and
understand.

Sincerely in Christ,
Christopher


More information about the Tutor mailing list