Michael Torrie 在 2023年1月25日 星期三凌晨3:05:44 [UTC+8] 的信中寫道: > On 1/23/23 18:58, Jach Feng wrote: > > More pathonic, but don't work. The '--' must be at index 1:-) > I'm very confused. Why are you even using argparse, since if you put -- > at index 1 then argparse wont't do any argument parsing at all. If all > you want is the expression on the command line, just access it directly. > If it's spread out with spaces, you can do something like this to put > it back together: > > expression = " ".join(sys.argv[1:] > > Otherwise the standard unix way of doing this is to require the user to > either provide the -- himself, or put the expression in quotes so it's > one unit. Maybe a condition is required before the modification, if len(sys.argv) > 1 and not '-h' in sys.argv: sys.argv.insert(1, '--') -- https://mail.python.org/mailman/listinfo/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 "... Jach Feng
- Re: How to make argparse accept &... Cameron Simpson
- Re: How to make argparse acce... Mike Baskin via Python-list
- Re: How to make argparse accept &... Michael Torrie
- Re: How to make argparse accept &... Jach Feng
- RE: How to make argparse acce... avi.e.gross
- Re: How to make argparse acce... Jach Feng
- Re: How to make argparse accept &... Jach Feng
- Re: How to make argparse accept "-4^2+5.3... Jach Feng
- Re: How to make argparse accept "-4^... Chris Angelico
- Re: How to make argparse accept "... Cameron Simpson
- Re: How to make argparse accept "-4^... Jach Feng
- Re: How to make argparse accept "... Chris Angelico
- Re: How to make argparse accept "... Weatherby,Gerard
- Re: How to make argparse accept "... David
- Re: How to make argparse accept "... Mats Wichmann
- Re: How to make argparse accept "-4^2+5.3... Jach Feng
- Re: How to make argparse accept "-4^... Chris Angelico