Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45332

Re: Determine actually given command line arguments

From "Colin J. Williams" <cjw@ncf.ca>
Newsgroups comp.lang.python
Subject Re: Determine actually given command line arguments
Date 2013-05-15 08:03 -0400
Organization National Capital Freenet, Ottawa, Ontario, Canada
Message-ID <kmvtj0$gbq$1@theodyn.ncf.ca> (permalink)
References <kmva9j$1hbk$1@gwdu112.gwdg.de>

Show all headers | View raw


On 15/05/2013 2:34 AM, Henry Leyh wrote:
> Hello,
> I am writing a program that gets its parameters from a combination of
> config file (using configparser) and command line arguments (using
> argparse).  Now I would also like the program to be able to _write_ a
> configparser config file that contains only the parameters actually
> given on the commandline.  Is there a simple way to determine which
> command line arguments were actually given on the commandline, i.e. does
> argparse.ArgumentParser() know which of its namespace members were
> actually hit during parse_args().
>
> I have tried giving the arguments default values and then looking for
> those having a non-default value but this is really awkward, especially
> if it comes to non-string arguments.  Also, parsing sys.argv looks
> clumsy because you have to keep track of short and long options with and
> without argument etc. i.e. all things that I got argparse for in the
> first place.
>
> Thanks && Greetings,
> Henry
Try sys.argv

Colin W.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Determine actually given command line arguments Henry Leyh <henry.leyh@ipp.mpg.de> - 2013-05-15 08:34 +0200
  Re: Determine actually given command line arguments "Colin J. Williams" <cjw@ncf.ca> - 2013-05-15 08:03 -0400
    Re: Determine actually given command line arguments Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-05-15 15:51 +0300
  Re: Determine actually given command line arguments Roy Smith <roy@panix.com> - 2013-05-15 08:24 -0400
    Re: Determine actually given command line arguments Dave Angel <davea@davea.name> - 2013-05-15 08:51 -0400
    Re: Determine actually given command line arguments Henry Leyh <henry.leyh@ipp.mpg.de> - 2013-05-15 14:52 +0200
      Re: Determine actually given command line arguments Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-05-15 14:00 +0100
        Re: Determine actually given command line arguments Henry Leyh <henry.leyh@ipp.mpg.de> - 2013-05-15 15:50 +0200
          Re: Determine actually given command line arguments Skip Montanaro <skip@pobox.com> - 2013-05-15 09:08 -0500
            Re: Determine actually given command line arguments Henry Leyh <henry.leyh@ipp.mpg.de> - 2013-05-15 16:39 +0200
              Re: Determine actually given command line arguments Skip Montanaro <skip@pobox.com> - 2013-05-15 09:51 -0500
          Re: Determine actually given command line arguments Wayne Werner <wayne@waynewerner.com> - 2013-05-15 09:16 -0500
      Re: Determine actually given command line arguments roy@panix.com (Roy Smith) - 2013-05-15 11:29 -0400
        Re: Determine actually given command line arguments Henry Leyh <henry.leyh@ipp.mpg.de> - 2013-05-16 07:43 +0200
          Re: Determine actually given command line arguments Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-05-16 09:08 +0300
            Re: Determine actually given command line arguments Henry Leyh <henry.leyh@ipp.mpg.de> - 2013-05-16 09:29 +0200

csiph-web