#argparse — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #argparse, aggregated by home.social.
-
From this week's Linux Update: Andrea Ciarrocchi shows you how to build smarter command-line tools with the argparse Python module
https://www.linux-magazine.com/Issues/2026/304/Adding-Arguments-with-argparse?utm_source=mlm
#Python #CommandLine #tools #argparse #scripts #utilities #programming -
From this week's Linux Update: Andrea Ciarrocchi shows you how to build smarter command-line tools with the argparse Python module
https://www.linux-magazine.com/Issues/2026/304/Adding-Arguments-with-argparse?utm_source=mlm
#Python #CommandLine #tools #argparse #scripts #utilities #programming -
Just released! 🚀
🐍 Python 3.15 alpha 3!
https://discuss.python.org/t/python-3-15-0-alpha-3/105325?u=hugovk
🔬 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: https://bsky.app/profile/savannah.dev/post/3m7svdqdeqs2x
⚠️ Better error messages#Python #Python315 #CPython #release #PEP799 #PEP686 #PEP782 #argparse
-
Just released! 🚀
🐍 Python 3.15 alpha 3!
https://discuss.python.org/t/python-3-15-0-alpha-3/105325?u=hugovk
🔬 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: https://bsky.app/profile/savannah.dev/post/3m7svdqdeqs2x
⚠️ Better error messages#Python #Python315 #CPython #release #PEP799 #PEP686 #PEP782 #argparse
-
So my side side project to print out help for ALL the commands and subcommands and so on for an #Argparse 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.
-
So my side side project to print out help for ALL the commands and subcommands and so on for an #Argparse 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.
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #Python
#programming #programacion #cmdline #argparse
https://ibolcode.net/roor/2025-09-parametros-linea-de-comandos--python
-
Had an enjoyable afternoon building a custom #cli #parser to replace #argparse 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. #comandline #python
-
Had an enjoyable afternoon building a custom #cli #parser to replace #argparse 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. #comandline #python
-
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.
-
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.
-
It's probably a case of #bikesheding, but I've been really unhappy with the #python 's #argparse 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 #cli
https://github.com/sumanthvepa/experiments/tree/develop/python/parse-dralithus-cmdline
-
It's probably a case of #bikesheding, but I've been really unhappy with the #python 's #argparse 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 #cli
https://github.com/sumanthvepa/experiments/tree/develop/python/parse-dralithus-cmdline
-
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.
https://github.com/python/cpython/issues/61252
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.
-
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.
https://github.com/python/cpython/issues/61252
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.
-
🎉 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.
https://discuss.python.org/t/vote-to-promote-savannah-ostrowski/70302
Savannah is the 9th new team member so far this year, which is the most we've had since 2012 🚀
-
🎉 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.
https://discuss.python.org/t/vote-to-promote-savannah-ostrowski/70302
Savannah is the 9th new team member so far this year, which is the most we've had since 2012 🚀
-
CLI Tools mit Python bauen?
Lerne in diesem Beitrag wie du mit Argparse Argumente direkt im Terminal für Python Tools verwenden kannst:
https://www.py-sec.de/2024/10/26/terminal-tools-mit-argparse-in-python-erstellen/ -
@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 https://www.cl.cam.ac.uk/~mr10/bcplman.pdf (p68).
1/2
-
@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 https://www.cl.cam.ac.uk/~mr10/bcplman.pdf (p68).
1/2
-
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.
-
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.
-
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 -
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 -
@davetron5000 @budu @pragprog Sorry it's out of print. Some tech books have a limited lifespan, although @OReillyMedia sometimes keeps "generally useful but potentially outdated" stuff available for a long time, e.g. I think they still have the original Ruby book from Matz available, which was written for #RubyLang 1.8 or 1.9 and isn't fully applicable to Ruby 3.2.2. 🤷
#CLI argument parsing can be challenging no matter what you use. #Fishshell #argparse has a lot of limitations cf. GNU #getopt.
-
@davetron5000 @budu @pragprog Sorry it's out of print. Some tech books have a limited lifespan, although @OReillyMedia sometimes keeps "generally useful but potentially outdated" stuff available for a long time, e.g. I think they still have the original Ruby book from Matz available, which was written for #RubyLang 1.8 or 1.9 and isn't fully applicable to Ruby 3.2.2. 🤷
#CLI argument parsing can be challenging no matter what you use. #Fishshell #argparse has a lot of limitations cf. GNU #getopt.
-
"
This command makes it easy for fish scripts and functions to handle arguments.
"Example from docs:
```
function mybetterfunction
argparse h/help s/second -- $argv
or returnif set -ql _flag_help
echo "mybetterfunction [-h|--help] [-s|--second] [ARGUMENT ...]"
return 0
endif set -ql _flag_second
echo $argv[2]
else
echo $argv[1]
echo $argv[3]
end
end
``` -
If you’re using #Python’s #argparse module to parse CLI arguments and want to have `--foo` and `--no-foo` flags, check out `action=argparse.BooleanOptionalAction`, which automatically creates `--no-foo` for you: https://docs.python.org/3/library/argparse.html#action
parser.add_argument('--foo', action=argparse.BooleanOptionalAction)
Requires 3.9 though. Simple solution for 3.8:
parser.add_argument('--foo', action='store_true')
parser.add_argument('--no-foo', dest='foo', action='store_false')
parser.set_defaults(foo=True) -
If you’re using #Python’s #argparse module to parse CLI arguments and want to have `--foo` and `--no-foo` flags, check out `action=argparse.BooleanOptionalAction`, which automatically creates `--no-foo` for you: https://docs.python.org/3/library/argparse.html#action
parser.add_argument('--foo', action=argparse.BooleanOptionalAction)
Requires 3.9 though. Simple solution for 3.8:
parser.add_argument('--foo', action='store_true')
parser.add_argument('--no-foo', dest='foo', action='store_false')
parser.set_defaults(foo=True) -
Argparse for golang. Just because `flag` sucks »
https://github.com/akamensky/argparse