command line arguments

Jon Hewer jonhewer at gmail.com
Thu Sep 1 10:32:06 CEST 2005


>What's the purpose of this utility?  Is it to do something with the URL?
>And the URL must always be specified?  What about the name?  Also
>mandatory, or optional?  The relationship between the two?

its just a simple rss reader.  i'm writing it almost purely just to
get me using language (i'm learning python)  it lets you save rss
feeds, and to do this one would specify a name and url (ie you have to
specify both), but there are other things it can do (remove a rss
feed, view a feed) hence i thought it was best to using command line
options

>You also could opt for the OptionParser in optparse..

Thanks, i'll take a look

On 8/31/05, Michael Hoffman <cam.ac.uk at mh391.invalid> wrote:
> wittempj at hotmail.com wrote:
> 
> > py>    parser.add_option("-n", "--name", dest="name", action="store",
> > py>                           help="enter a name")
>  > py>    parser.add_option("-u", "--url", action="store", dest="url",
>  > help = "enter an url")
> 
> It's worth noting that this will have the same effect and involves less
> repetitive typing:
> 
> parser.add_option("-n", "--name", help="enter a name")
> parser.add_option("-u", "--url", help="enter a url")
> 
> Discovering this has made optparse usage much more painless for me, and
> also reduces the incidence of those nasty multiple line option additions.
> 
> Although I should note for the record that I agree with Peter Hansen
> that if the arguments are not *optional* then they should not be made
> options in this manner.
> --
> Michael Hoffman
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list