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
I have some tools such as sudo-ssh where an option might appear after the first positional parameter but I don't want the tool to interpret it as an option for it. For instance, without nargs=argparse.REMAINDER this command won't do what I want:
sudo-ssh foo find / -name bar
Instead, sudo-ssh complains about the -n option that it knows nothing about but the option isn't forsudo-ssh! It's for find when the tool runs the command on the remote foo machine!
WIthout nargs=argparse.REMAINDER, you need to do something like this instead to protect the faux-option:
sudo-ssh foo -- find / -name bar
But if nargs=argparse.REMAINDER is used, either use does what I want.
While using this option could make -- unnecessary, it could also make the argparse help less accurate. Right now, I can rely on argparse automatically building the command string for online help.
It's not a major pain to use --. Sometimes I make use of it even when it's not necessary and that's not a bad practice.
I have some tools such as
sudo-ssh
where an option might appear after the first positional parameter but I don't want the tool to interpret it as an option for it. For instance, withoutnargs=argparse.REMAINDER
this command won't do what I want:Instead,
sudo-ssh
complains about the-n
option that it knows nothing about but the option isn't forsudo-ssh
! It's forfind
when the tool runs the command on the remotefoo
machine!WIthout
nargs=argparse.REMAINDER
, you need to do something like this instead to protect the faux-option:But if
nargs=argparse.REMAINDER
is used, either use does what I want.See:
remainder
script in Python/fun repoThe text was updated successfully, but these errors were encountered: