Re: optparse - required options

Discussion in 'Python' started by Omari Norman, Aug 23, 2007.

  1. Omari Norman

    Omari Norman Guest

    On Mon, Aug 20, 2007 at 05:31:00PM -0400, Jay Loden wrote:
    > Robert Dailey wrote:
    > > Well, I don't know what is wrong with people then. I don't see how
    > > required arguments are of bad design. Some command-line applications are
    > > built around performing tasks based on information received. Compilers,
    > > for example. A compiler can't do much of anything unless you give it at
    > > the very least a filename. So, a --file command would most definitely be
    > > one required argument. Anyway, I'm not trying to start a debate on this
    > > issue. I have my own implementation for required arguments at the
    > > moment, I am just a little bit surprised that this module doesn't make
    > > it convenient. It would definitely help on code duplication.
    > >
    > > Thanks for your response.

    >


    > I tend to agree...while "required option" may be an oxymoron in
    > English, I can think of quite a few scripts I've written myself (in
    > various languages) that needed at least some kind of user input to
    > operate. At least the documentation points to some examples for
    > helpful hints, example code is a lot better than nothing ;)


    The idea with optparse is not that programs should not require certain
    information on the command line; rather, the idea is that this
    information should be positional arguments, not 'options'.

    That is, to use the compiler example:

    compiler file

    is preferred if a file argument is necessary.

    compiler --file file

    is not preferred.


    --
    Due to some violent content, viewer discretion is advised.
     
    Omari Norman, Aug 23, 2007
    #1
    1. Advertising

  2. Omari Norman wrote:
    > On Mon, Aug 20, 2007 at 05:31:00PM -0400, Jay Loden wrote:
    >> Robert Dailey wrote:
    >>> Well, I don't know what is wrong with people then. I don't see how
    >>> required arguments are of bad design.

    >
    >> I tend to agree...while "required option" may be an oxymoron in
    >> English, I can think of quite a few scripts I've written myself (in
    >> various languages) that needed at least some kind of user input to
    >> operate.

    >
    > The idea with optparse is not that programs should not require certain
    > information on the command line; rather, the idea is that this
    > information should be positional arguments, not 'options'.
    >
    > That is, to use the compiler example:
    >
    > compiler file
    >
    > is preferred if a file argument is necessary.
    >
    > compiler --file file
    >
    > is not preferred.


    I agree with the optparse philosophy, but Practicality Beats Purity.
    That's why I was convinced to add "required options" to argparse --
    there are too many applications that want that kind of interface.
    *I* don't write applications with interfaces like that, but enough
    people do that the use case should really be supported.

    STeVe
     
    Steven Bethard, Aug 24, 2007
    #2
    1. Advertising

  3. Omari Norman

    Steve Holden Guest

    Steven Bethard wrote:
    > Omari Norman wrote:
    >> On Mon, Aug 20, 2007 at 05:31:00PM -0400, Jay Loden wrote:
    >>> Robert Dailey wrote:
    >>>> Well, I don't know what is wrong with people then. I don't see how
    >>>> required arguments are of bad design.
    >>> I tend to agree...while "required option" may be an oxymoron in
    >>> English, I can think of quite a few scripts I've written myself (in
    >>> various languages) that needed at least some kind of user input to
    >>> operate.

    >> The idea with optparse is not that programs should not require certain
    >> information on the command line; rather, the idea is that this
    >> information should be positional arguments, not 'options'.
    >>
    >> That is, to use the compiler example:
    >>
    >> compiler file
    >>
    >> is preferred if a file argument is necessary.
    >>
    >> compiler --file file
    >>
    >> is not preferred.

    >
    > I agree with the optparse philosophy, but Practicality Beats Purity.
    > That's why I was convinced to add "required options" to argparse --
    > there are too many applications that want that kind of interface.
    > *I* don't write applications with interfaces like that, but enough
    > people do that the use case should really be supported.
    >

    Well, here's to software producers who listen to their users!

    regards
    Steve
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://del.icio.us/steve.holden
    --------------- Asciimercial ------------------
    Get on the web: Blog, lens and tag the Internet
    Many services currently offer free registration
    ----------- Thank You for Reading -------------
     
    Steve Holden, Aug 24, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Goodger

    Re: Iterating over optparse options

    David Goodger, Jun 25, 2003, in forum: Python
    Replies:
    0
    Views:
    1,010
    David Goodger
    Jun 25, 2003
  2. Gregory (Grisha) Trubetskoy

    Required options in optparse

    Gregory (Grisha) Trubetskoy, Oct 4, 2003, in forum: Python
    Replies:
    0
    Views:
    428
    Gregory (Grisha) Trubetskoy
    Oct 4, 2003
  3. Steven Bethard
    Replies:
    0
    Views:
    412
    Steven Bethard
    May 10, 2006
  4. Rocky Zhou
    Replies:
    3
    Views:
    333
    Steven Bethard
    Mar 18, 2007
  5. icarus

    optparse options

    icarus, May 19, 2009, in forum: Python
    Replies:
    2
    Views:
    391
    Mike Kazantsev
    May 20, 2009
Loading...

Share This Page