Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: want to show list of available options and arguments in mycommand line utility

Reply
Thread Tools

Re: want to show list of available options and arguments in mycommand line utility

 
 
Peter Otten
Guest
Posts: n/a
 
      09-16-2012
Santosh Kumar wrote:

> I have a script that takes an which basically takes a command line
> argument and prints after processing. If I don't give the argument to
> the script, it gives me a ValueError:
>
> ValueError: need more than 1 value to unpack
>
> I was trying to utilizing this space, if there is no argument I want it
> to show:
> usages: myscriptpy [option] [argument]
>
> options:
> --help print this help message and exit
>
> Nothing more than that. I was looking on the argparse module, it can
> do the stuffs I want, but
> I don't to rewrite and mess up my current script. What should I do?


Learning to use the argparse module is a worthwhile endeavour. You should
rewrite and not mess up your script. This is easier if you write unit tests
to accompany the code doing the "real work".

Don't forget to use version control (see http://hginit.com/ for example) to
help you back out if something goes awry.

Also note that learning to throw away suboptimal code is important, too.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
want to show list of available options and arguments in my commandline utility Santosh Kumar Python 2 09-16-2012 07:29 AM
Re: When running Ant on command line, how to not-show its WARNING messages and only show ERROR message? Roedy Green Java 5 12-13-2011 05:49 PM
Re: When running Ant on command line, how to not-show its WARNING messages and only show ERROR message? John B. Matthews Java 0 12-09-2011 05:19 PM
why doesn't this "belongs_to" line of code, using options override,not work??? (need help using belongs_to with options) Greg Hauptmann Ruby 1 10-30-2008 10:44 PM
Library functions for handling command line arguments or options lovecreatesbea...@gmail.com C++ 3 01-11-2007 09:33 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57