Custom help format for a choice argparse argument

Cameron Simpson cs at cskk.id.au
Fri Jan 27 16:06:39 EST 2023


On 27Jan2023 15:31, Ivan "Rambius" Ivanov <rambiusparkisanius at gmail.com> wrote:
>I am developing a script that accepts a time zone as an option. The
>time zone can be any from pytz.all_timezones. I have
>
>def main():
>    parser = argparse.ArgumentParser()
>    parser.add_argument("-z", "--zone", choices=pytz.all_timezones)
[...]
>
>It works, but when I run it with the -h option it dumps all entries in
>pytz.all_timezones.

What happens if you just presupply a `help=` parameter in 
`add_argument`?

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list