How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?
Greg Ewing
greg.ewing at canterbury.ac.nz
Mon Jan 23 18:33:18 EST 2023
>> On 2023-01-22 at 18:19:13 -0800,
>> Jach Feng <jfong at ms4.hinet.net> wrote:
>>> 1) Modify the sys.argv by inserting an item '--' before parsing it, ie.
>>> sys.argv.insert(1, '--')
>>> args = parser.parse_args()
If you do that, you'll never be able to have any actual options, so
using argparse seems like overkill. Just pull the argument out of
argv directly.
--
Greg
More information about the Python-list
mailing list