configargparse - reading option from config only

Richard Damon Richard at Damon-Family.org
Thu Aug 26 21:18:47 EDT 2021


On 8/26/21 6:01 AM, Loris Bennett wrote:
> Hi,
>
> When using configargparse, it seems that if a value is to be read from a
> config file, it also has to be defined as a command-line argument in
> order to turn up as an attribute in the parser namespace.  
>
> I can sort of see why this is the case, but there are also some options
> I would like to read just from the config file and not have them
> available as command-line options.  This would be, say, to prevent the
> number of options on the command-line from becoming bloated by
> little-used settings.
>
> Is there an elegant way to do this?
>
> Cheers,
>
> Loris
>
Look at the read() member function to supply the file name to read. Then
in the config object there will be sections for each section in the
config file. No need for any of these to be 'options'

-- 
Richard Damon



More information about the Python-list mailing list