Updated my smart help text formatter for #argparse #gist: https://gist.github.com/panzi/b4a51b3968f67b9ff4c99459fb9c5b3d #Python
Updated my smart help text formatter for #argparse #gist: https://gist.github.com/panzi/b4a51b3968f67b9ff4c99459fb9c5b3d #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.
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
How to create flask web app with python
#python #flask @python_discussions @htmlallthethings #argparse
https://github.com/scheehan/gen_flask_web_app_with_script
https://discu.eu/?q=https%3A%2F%2Fgithub.com%2Fscheehan%2Fgen_flask_web_app_with_script.git
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 🚀
🎖 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: http://eepurl.com/iZb4lU
Subscribe for more at: https://bit.ly/MyVoyageOf_Discovery
#python #Streamlit #visualisation #MIT #data #argparse #Atomic_Habit #software #IT
@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.
@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 return
if set -ql _flag_help
echo "mybetterfunction [-h|--help] [-s|--second] [ARGUMENT ...]"
return 0
end
if set -ql _flag_second
echo $argv[2]
else
echo $argv[1]
echo $argv[3]
end
end
```
New video up. https://youtu.be/10rlZ_js7kg #python #argparse #actionclass #howto #tutorial #guide
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)
@funkylab That is hilarious, more so with "WontFix" https://github.com/python/cpython/issues/96994
#Python #argparse