On 1/22/23 11:44, Stefan Ram wrote: > Jach Feng <jf...@ms4.hinet.net> writes: >> e:\Works\Python>py infix2postfix.py "-4^2+5.3*abs(-2-1)/2" > > Well, it's a nice exercise! But I only made it work for the > specific example given. I have not tested whether it always > works.
Haha. Yes a nice exercise, but has nothing to do with the original question which is how to convince argparse to accept a string like that without thinking it's a switch. Many unix utilities treat "--" as a special argument that turns off argument parsing for the rest of the command line. Maybe argparse follows this convention too; I don't know. But if it did you'd do: infix2postfix.py -- "-4^2+5.3*abs(-2-1)/2" -- https://mail.python.org/mailman/listinfo/python-list