python - In optparse module - command line option parser, how to confirm if an option was not provided? -


from python docs:

"option.dest : if option’s action implies writing or modifying value somewhere, tells optparse write it: dest names attribute of options object optparse builds parses command line."

can put check on name of attribute (dest) check if it's value provided? say, want perform action determine it's value when no value provided in cli, don't have fixed default value.

checking against 'none' not work.

you use default value of none such options, cannot entered on command line. can check like

if opts.optional_value none:     # action option not given else:     # use value command line 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -