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

David bouncingcats at gmail.com
Wed Jan 25 18:10:23 EST 2023


On Thu, 26 Jan 2023 at 04:24, Jach Feng <jfong at ms4.hinet.net> wrote:
> Chris Angelico 在 2023年1月25日 星期三下午1:16:25 [UTC+8] 的信中寫道:
> > On Wed, 25 Jan 2023 at 14:42, Jach Feng <jf... at ms4.hinet.net> wrote:

> > You're still not really using argparse as an argument parser. Why not
> > just do your own -h checking? Stop trying to use argparse for what
> > it's not designed for, and then wondering why it isn't doing what you
> > expect it to magically know.

> I just don't get what you mean?

Hi, I am writing because there seems to be a communication
problem here, not a programming problem. The thread is long
and seems to be making no progress.

You seem like a traveller who is lost and keeps looking at the
map, but they have the wrong map for where they are.

You seem to be not understanding the purpose of argparse.

In this thread, you have not mentioned any reason that requires
the use of argparse.

argparse is intended to help when your program accepts
>>> more than one kind of argument <<<
and then uses those different kinds of argument
>>> for different purposes <<<.

The programmer can handle that situation without argparse.
But argparse makes it easier.

In this thread, you have not described your program as accepting
different kinds of arguments. Therefore the people replying to you
are telling you that you do not need it.

You seem to be not listening to that, and you have not explained why,
you seem to just keep ignoring what people are telling you.

If you disagree with this, then a way forward is for you to think harder
about what benefits you are getting in your program by using argparse,
and >>> explain those benefits clearly to your readers here <<<.

An alternative approach would be for you to remove argparse from
your program, and try to write your program without it. And
then ask here about any difficulties that you have with doing that,
and I imagine people will be glad to help you.

All of the replies you have received so far are trying to help you,
even if you don't feel that. Good luck.


More information about the Python-list mailing list