How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

Jach Feng jfong at ms4.hinet.net
Mon Jan 23 21:11:46 EST 2023


Greg Ewing 在 2023年1月24日 星期二清晨7:33:43 [UTC+8] 的信中寫道:
> >> On 2023-01-22 at 18:19:13 -0800, 
> >> Jach Feng <jf... 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
Any easy way to "pull the argument out of argv directly" before parse_args()?:-)


More information about the Python-list mailing list