Chris Angelico 在 2023年1月24日 星期二清晨5:00:27 [UTC+8] 的信中寫道: > On Tue, 24 Jan 2023 at 07:47, Cameron Simpson <c...@cskk.id.au> wrote: > > > > But for Jach Feng: the "--" is really expected as something the user > > does when they invoke your programme, _explicitly_ saying that what > > follows from here is not an argument. So the user is expected to type: > > > > your_script -x -y -- "-4^2+5.3*abs(-2-1)/2" > > > > where there are -x and -y options, then end of options, then an > > argument, which would look like an option if there wasn't the "--" > > argument. > And if you DON'T expect the user to enter the "--", then why use > argparse? You can just check argv directly to get your arguments. > > This entire thread is a massive "how can I use X to do Y?" problem. > > ChrisA The '--' requirement makes its usage less instinctive, and handling argv directly makes me loss the benefit of using '-h':-) -- https://mail.python.org/mailman/listinfo/python-list
- Re: How to make argparse accept &... Grant Edwards
- Re: How to make argparse accept "-4^2+5.3... Mark Bourne
- Re: How to make argparse accept "-4^2+5.3... Cameron Simpson
- Re: How to make argparse accept "-4^2+5.3... Michael Torrie
- Re: How to make argparse accept "-4^2+5.3... Jach Feng
- Re: How to make argparse accept "-4^... 2QdxY4RzWzUUiLuE
- Re: How to make argparse accept "... Cameron Simpson
- Re: How to make argparse accept &... Chris Angelico
- Re: How to make argparse accept &... Greg Ewing
- Re: How to make argparse acce... Jach Feng
- Re: How to make argparse accept &... Jach Feng
- Re: How to make argparse acce... Chris Angelico
- Re: How to make argparse... Thomas Passin
- Re: How to make argp... Mike Baskin via Python-list
- Re: How to make argp... Thomas Passin
- Re: How to make argp... Weatherby,Gerard
- Re: How to make argp... Dennis Lee Bieber
- Re: How to make argparse accept "-4^... Jach Feng
- Re: How to make argparse accept "... Cameron Simpson
- Re: How to make argparse accept &... Mike Baskin via Python-list
- Re: How to make argparse accept "... Michael Torrie