#argparse

Hugo van Kemenadehugovk
2025-12-16

Just released! 🚀

🐍 Python 3.15 alpha 3!

discuss.python.org/t/python-3-

🔬 PEP 799: A new high-frequency statistical sampling profiler and dedicated profiling package
💬 PEP 686: Python now uses UTF-8 as the default encoding
🌊 PEP 782: A new PyBytesWriter C API to create a Python bytes object
🎨 Colour code snippets in argparse help: bsky.app/profile/savannah.dev/
⚠️ Better error messages

Hugo van Kemenadehugovk
2025-11-14

🎨 Old news: I added colour to argparse CLI help in last month's Python 3.14.

⭐ New news: I just added colour to ruff and ty's help so they can catch up (uv already had colour).

Three terminal windows: first shows the help for argparse CLIs, with headings, options and arguments in different colour. The next is ruff and ty, with similar but different colour scheme. And the last window is uv with the same colour scheme as ruff and ty.
Буквоед :bookworms:IamnotHayato@bookwor.ms
2025-11-10

Pythonを避けてきた理由やNeovimが好きになれない理由も似たような感じです。保守的なもので……

Pythonは2系から3系への破壊的移行は言うに及ばず、最近でもgetoptみたいな基本的な機能でゴタゴタしていたりとか、後方互換性という考えは無いんだろうなと思うとちょっと使いたくない感じです (使いますけど)

【Python3.14】getoptとoptparseが非推奨でなくなった #argparse - Qiita qiita.com/rana_kualu/items/2ec

Neovimは最近会社のPCで使っていいことになって (気付いたのは10/22ですがいつから使えたのかは不明)、Windows 11 23H2にアップデートしたところEmacsの起動に30分近く掛かるように (原因はWindowd Defenderのせいだろうなと見当はついているのですが管理者権限がないと手出しできないため解決不能) なったこともあり渡りに船と乗り換えたのですが、Vimからの移行を意識していそうな割にはOptionの規定値がVimと違うもの (hlsearchとか) がちらほらあって戸惑っています。
規定値の説明は確かにhelpにはあるけれど、そのことについて事前に知る手段は特にないので使ってみたら予想外の動作をして驚いて調べて比較してようやく気付く、という感じで不親切な印象は拭えず。
Vimだったら規定値は変えずにdafaults.vimで対応するところだよなあと思ったり。後方互換性(ry

Matthew Martinmistersql
2025-09-29

So my side side project to print out help for ALL the commands and subcommands and so on for an app. Although it will make best efforts for other commands.

`totalhelp pipx` -- seems to work.
`totalhelp llm` -- incredibly slow.

also has library version for

`my_command --totalhelp` and it shows all the help for all the commands.

pypi.org/project/totalhelp/0.1

sumanthvepasumanthvepa
2025-05-18

Had an enjoyable afternoon building a custom to replace in our internal tooling. I like its ease of use. But it is a custom parser and works only for my specific use case, but for use case it does more than argparse can and is simpler to use.

A custom command line parser with a simple API.

@sumanthvepa

argparse is maybe-okay for simple things, but I don't use it for pretty much anything anymore. Have you tried one of the other extant packages that provide higher-level, more-powerful option handling?

I use `click` extensively for complex multiple-command CLI tools.

#click #optparse #argparse #CLI

sumanthvepasumanthvepa
2025-05-17

It's probably a case of , but I've been really unhappy with the 's library for a while now. It's okay for run of the mill tools, but fails for more complex command line tools that have subcommands and complex options like --no-except to negate an option.

This is my first cut writing a command line parser for a

github.com/sumanthvepa/experim

Kevin Bowen (has moved) :xfce:kevinbowen@fosstodon.org
2025-05-08

Migrated my user-space environement over to #Python 3.14.0b1 today.

Nice to see the majority of the packages I use work without issue, so far.

Plus, I get that all that pretty colored output from #argparse!

#EyeCandy #Terminal #CLI

Terminal output from a python script showing colored output on a help command

usage: create_gh_issue_bug.py [-h] [-f {django,drf,flask,fastapi,all}] [--version]

run gh commands on groups of projects ordered by framework.

options:
  -h, -help         show this help message and exit
  -f, --framework {django,drf, flask, fastapi, all}
                    specify a web framework group to run commands on (default: None)
  --version         show program's version number and exit
2025-04-24

Huh, there is really no way in #Python #argparse to say "print full help, not only usage when an error occurs"?

I mean, besides
```
parser = argparse.ArgumentParser()
parser.format_usage = parser.format_help
```
(or similar monstrosities)

2024-12-27

TIL: #Python's #argparse module cannot parse arguments that start with a dash. It always expects them to be a flag and then throws an error if that flag is not defined.

github.com/python/cpython/issu

My use case: I have a command with subparsers/subcommands, and I'd like one of these subcommands to just take all of argv that follows its name and pass it on to someplace else.

mycmd subcmd foo -bar --baz

subcmd.add_argument("args", nargs="*") doesn't work.

Guess I'll have to resort to a hack.

Hugo van Kemenadehugovk
2024-11-14

🎉 Please welcome @savannah as the newest member of the Python core team!

She has recently been doing lots of excellent work on the new JIT and giving argparse some long-overdue attention.

discuss.python.org/t/vote-to-p

Savannah is the 9th new team member so far this year, which is the most we've had since 2012 🚀

hugovk.github.io/python-core-d

Bar chart of new core developers by year.

Starting in 1989 with one, there were one or two new core devs per year in the 90s.

The 2000s had around 10 added per year.

The 2010s had around 5 per year.

2020 had 5 new, 2021 had 3, 2022 had 8, 2023 had 5, and this year has had 8 so far.
Sarfraaz Ahmedasarfraaz
2024-09-19

🎖 Atomic Habits for Software Professionals
Using Streamlit for your data visualisation
Python Data Analytics Study Guide
Using argparse in Python

Read more in the latest edition of MyVoD at: eepurl.com/iZb4lU
Subscribe for more at: bit.ly/MyVoyageOf_Discovery

2024-09-05

@mhd I was quite fond of Amiga #CLI syntax, which many did not consider a proper #Amiga subsystem because of #BCPL, but it allowed commands to pre-declare the arguments in a uniform, documented way similar to Python’s #argparse.

It’s actually handled by BCPL’s rdargs() function, documented in cl.cam.ac.uk/~mr10/bcplman.pdf (p68).

1/2

2024-06-12

TIL that #python #argparse can't support negative floating numbers as arguments. Like, the bug is closed RESOLVED, even though if you read through the actual resolution is WONTFIX.

They just decided that argparse (in the stdlib!) is too complex to update and we should use a different library. So now I have to port my app and in the meantime "can't resolve ticket, bug is upstream" is not very satisfying.

Validates #rustlang's strategy of keeping std small to avoid exactly this type of issue.

skribe 🇺🇦 :verified_mustard:skribe@aus.social
2024-02-28

Is there an obvious way for argparse to check if the source file and destination file are the same? ie. the user has accidentally inputted the source file twice?

This doesn't work:

if args.source_file == args.dest_file:
do something

#Python #Argparse #Noob

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst