You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be convenient if I can specify that given *args are required.
Here I'm able to convert all captured *numbers to float, but I cannot find a way to require numbers to be non-empty.
I'm using a SystemExit exception as a workaround, but if begins printed out an error and the usage statement for me, that would be much more convenient.
I often require at least one positional argument when using *args so this is a common use case for me.
importbegin@begin.start@begin.convert(numbers=float)defmain(*numbers : "numbers to add"):
"""Add the given numbers"""ifnumbers:
print(sum(numbers)
else:
raiseSystemExit("No numbers to add!")
The text was updated successfully, but these errors were encountered:
What you are saying is that it would be nice to have finer specification of nargs argument to argparse's add_argument. Maybe it could be done with something like @begin.params(numbers={'nargs':'+'}). Maybe having a lot of chained decorators is not so cool so @begin.convert could be included in @begin.params(numbers={'type':float, 'nargs':'+'}).
It would be convenient if I can specify that given
*args
are required.Here I'm able to convert all captured
*numbers
tofloat
, but I cannot find a way to requirenumbers
to be non-empty.I'm using a
SystemExit
exception as a workaround, but ifbegins
printed out an error and the usage statement for me, that would be much more convenient.I often require at least one positional argument when using
*args
so this is a common use case for me.The text was updated successfully, but these errors were encountered: