Python optparse: parse.error()---->TypeError: error() missing 1 required positional argument: 'msg' -


i having trouble running trace route module on new python 3.4.3. on previous versions of python able run module yet unable to. keep receiving traceback error when try calling parser.error() function of optparse.

typeerror: error() missing 1 required positional argument: 'msg'*  

here snippet of code

if __name__ == "__main__":     parser = optparse.optionparser(usage="%prog [options] hostname")     parser.add_option("-p", "--port", dest="port",                       help="port use socket connection [default:%default]",                       default=33434, metavar="port")     parser.add_option("-m", "--max-hops", dest="max_hops",                       help="max hops before giving [default: %default]",                       default=30, metavar="maxhops")      (options, args) = parser.parse_args()     if len(args) != 1:         parser.error()     else:         dest_name = args[0]      sys.exit(main(dest_name=dest_name,         port=int(options.port),         max_hops=int(options.max_hops))) 

the error keeps occuring @ "if" statement

if len(args) != 1:     parser.error() 

i tried this

if len(args) != 1:     parser.error("incorrect number of arguments") 

when tried run module time received error instead

   usage: traceroute.py [options] hostname    traceroute.py: error: incorrect number of arguments 

i love feedback on how fix code in order prevent error , more information on how use optparse library in python 3.4.3


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -