[Tutor] How to update only set CLI args?

Alex Kleider alexkleider at gmail.com
Mon Jan 17 17:36:36 EST 2022


Have you considered/looked at docopt?
>>> python3 -m pip install docopt

On Mon, Jan 17, 2022 at 6:02 AM Leam Hall <leamhall at gmail.com> wrote:

> Writing a CLI app in Python 3.10. There's a "defaults" dict, a config file
> that gets read into a dict, and command line arguments that can be passed
> in.
>
>    defaults = {'table':'people'}
>    defaults.update(config)
>    defaults.update(vars(args))
>
> The issue is that if an argument is not set on the command line, the
> args.item has a value of "None", which then overwrites any value in
> defaults or config. How do I update just the set args?
>
> Thanks!
>
> Leam
> --
> Site Automation Programmer (reuel.net/resume)
> Scribe: The Domici War     (domiciwar.net)
> General Ne'er-do-well      (github.com/LeamHall)
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list