arguments - python: argparser.add_argument() causes ArgumentError() -


i've encountered strange issue — when i'm using argparser.add_argument() method i'm getting argumenterror().

from oauth2client.tools import argparser, run_flow  if __name__ == "__main__":   argparser.add_argument("--videoid", default="l-onkk1crnu",     help="id of video like.") 

i'm running code pdb, that's error i'm getting:

(pdb) n argumenterror: argumenterror() > c:\py\googleapitest.py(48)<module>()->none -> help="id of video like.") 

that's root cause:

c:\python27\lib\argparse.pyc in _handle_conflict_error(self, action, conflicting_actions)    1452                                      option_string, action    1453                                      in conflicting_actions]) -> 1454         raise argumenterror(action, message % conflict_string) 

i'm getting error if i'm not passing "help" param.

what doing wrong?

from auth2 docs:

the oauth2client.tools.run_flow() function controlled command-line flags, , python standard library argparse module must initialized @ start of program. argparse included in python 2.7+, , available separate package older versions. following shows example of how use function:

import argparse oauth2client import tools  parser = argparse.argumentparser(parents=[tools.argparser]) flags = parser.parse_args() 

back dead

the original problem arises after restarting script in environment such pdb. on restart, main script runs again old imported scripts, including changes oath2client.tools.argparser remain. solution stated in docs, create own parser oauth2client's parser parent. way, add arguments parser recreated on startup.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -