Jach Feng 在 2023年1月22日 星期日上午11:11:22 [UTC+8] 的信中寫道:
> Fail on command line,
>
> e:\Works\Python>py infix2postfix.py "-4^2+5.3*abs(-2-1)/2"
> usage: infix2postfix.py [-h] [infix]
> infix2postfix.py: error: unrecognized arguments: -4^2+5.3*abs(-2-1)/2
>
> Also fail in REPL,
>
> e:\Works\Python>py
> Python 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:08:11) [MSC v.1928 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import argparse
> >>> parser = argparse.ArgumentParser(description='Convert infix notation to
> >>> postfix')
> >>> parser.parse_args("-4^2+5.3*abs(-2-1)/2")
> usage: [-h]
> : error: unrecognized arguments: - 4 ^ 2 + 5 . 3 * a b s ( - 2 - 1 ) / 2
>
> Just can't figure out where is wrong!?
>
> --Jach
I appreciate every comment/suggestion in this thread even sometimes I may not
fully understand what they mean. To me, argparse has been just a tool which I
can use in a CLI app. I use it as long as the situation allows, even it's as
simple as only one positional argument is needed. Now I understand some oppose
this idea and saying that you shouldn't use a kitchen knife to cut a cake:-)
--
https://mail.python.org/mailman/listinfo/python-list
- Re: How to make argparse accept... Jach Feng
- Re: How to make argparse accept "-4... Jach Feng
- Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/... Jach Feng
- Re: How to make argparse accept "-4^2+5.3*abs(-... Chris Angelico
- Re: How to make argparse accept "-4^2+5.3*a... Cameron Simpson
- Re: How to make argparse accept "-4^2+5.3*abs(-... Jach Feng
- Re: How to make argparse accept "-4^2+5.3*a... Chris Angelico
- Re: How to make argparse accept "-4^2+5.3*a... Weatherby,Gerard
- Re: How to make argparse accept "-4^2+5.3*a... David
- Re: How to make argparse accept "-4^2+5.3*a... Mats Wichmann
- Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/... Jach Feng
- Re: How to make argparse accept "-4^2+5.3*abs(-... Chris Angelico
- Re: How to make argparse accept "-4^2+5.3*abs(-... Michael Torrie
- Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/... Jach Feng
- Re: How to make argparse accept "-4^2+5.3*abs(-... Mark Bourne
- Re: How to make argparse accept "-4^2+5.3*a... Jach Feng
- Re: How to make argparse accept "-4^2+5... Chris Angelico
- Re: How to make argparse accept "-4^2+5... Cameron Simpson
- Re: How to make argparse accept "-4... 2QdxY4RzWzUUiLuE
- RE: How to make argparse accept &qu... avi.e.gross
- Re: How to make argparse accept... Peter J. Holzer
