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

2023-01-24 Thread Cameron Simpson
On 25Jan2023 16:15, Chris Angelico wrote: On Wed, 25 Jan 2023 at 14:42, Jach Feng wrote: I was happy working with argparse during implement my script. To save the typing, I used a default equation for testing. Sure, but what benefit was it bringing you? Just the usage (help) message? Did

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

2023-01-24 Thread Chris Angelico
On Wed, 25 Jan 2023 at 14:42, Jach Feng wrote: > I was happy working with argparse during implement my script. To save the > typing, I used a default equation for testing. > > sample = "-4^2+5.3*abs(-2-1)/2, abs(Abc)*(B+C)/D, (-3) * > sqrt(1-(x1/7)*(y1/7)) * sqrt(abs((x0-4.5)/(y0-4)))" > parser

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

2023-01-24 Thread Jach Feng
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\Pytho

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

2023-01-24 Thread Jach Feng
avi.e...@gmail.com 在 2023年1月25日 星期三清晨6:39:13 [UTC+8] 的信中寫道: > If I understood the issue, the problem is the unary minus at the start of the > expression. > > So if you know the expression is in that argument, would it make sense to pad > it in one of many ways that are otherwise harmless? > >

Re: bool and int

2023-01-24 Thread rbowman
On Wed, 25 Jan 2023 12:14:50 +1100, Chris Angelico wrote: > So the problem isn't that I'm trying to write Python in C#, but that I'm > trying to write code that would work on pretty much *any other C-family > language*, but doesn't work on C#. I could use those techniques in > plenty of C-derived

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

2023-01-24 Thread Jach Feng
Michael Torrie 在 2023年1月25日 星期三凌晨3:05:44 [UTC+8] 的信中寫道: > On 1/23/23 18:58, Jach Feng wrote: > > More pathonic, but don't work. The '--' must be at index 1:-) > I'm very confused. Why are you even using argparse, since if you put -- > at index 1 then argparse wont't do any argument parsing at all

Re: bool and int

2023-01-24 Thread Grant Edwards
On 2023-01-25, Mike Baskin via Python-list wrote: > Will all of you please stop sending me emails Oh dear. You might want to try unsubscribing from the list. Telling everybody to stop using the mailing list and newsgroup is a bit silly. -- Grant -- https://mail.python.org/mailman/listinfo/py

Re: bool and int

2023-01-24 Thread Chris Angelico
On Wed, 25 Jan 2023 at 12:43, wrote: > Python has a different philosophy than some other languages with strong > typing. In some of those, you would not be allowed to add or multiply at > random but would need to convert parts of your calculation to all be the > same, such as a 32-bit integer. You

RE: bool and int

2023-01-24 Thread avi.e.gross
Python yet again is being asked why something is the way it is and not as someone insists it should be. It is a tool to be used the way it SAYS it works so the bug is perhaps in the user and their expectations. It is what it is and would break lots of things if changed without much thought. Every

Re: bool and int

2023-01-24 Thread David
On Wed, 25 Jan 2023 at 12:19, Mike Baskin via Python-list wrote: > Will all of you please stop sending me emails Hi. We don't have the power to do that. Because this is a public list, which works by people adding and removing themselves. You, or perhaps someone messing with you, added your email

Re: bool and int

2023-01-24 Thread Chris Angelico
On Wed, 25 Jan 2023 at 12:20, Mike Baskin via Python-list wrote: > > Will all of you please stop sending me emails Learn to manage your own mailing list subscription. HINT: Look at the *ENTIRE* email, not just the bit up the top that makes you angry. > Sent from my iPhone Ahh, I see the problem

Re: bool and int

2023-01-24 Thread Mike Baskin via Python-list
Will all of you please stop sending me emails Sent from my iPhone > On Jan 24, 2023, at 2:59 PM, rbowman wrote: > > On Mon, 23 Jan 2023 23:22:00 -0500, Dino wrote: > >> $ python Python 3.8.10 (default, Mar 15 2022, 12:22:08) >> [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "lice

Re: bool and int

2023-01-24 Thread Chris Angelico
On Wed, 25 Jan 2023 at 10:32, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2023-01-25 at 08:58:06 +1100, > Chris Angelico wrote: > > > On Wed, 25 Jan 2023 at 08:22, MRAB wrote: > > > For backwards compatibility, bool was made a subclass of int. > > > > Plus, it's really REALLY handy in quit

Re: bool and int

2023-01-24 Thread 2QdxY4RzWzUUiLuE
On 2023-01-25 at 08:58:06 +1100, Chris Angelico wrote: > On Wed, 25 Jan 2023 at 08:22, MRAB wrote: > > For backwards compatibility, bool was made a subclass of int. > > Plus, it's really REALLY handy in quite a lot of situations. > > > > C# is pickier, which I guess is a good thing. > > > > N

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

2023-01-24 Thread Dennis Lee Bieber
On Tue, 24 Jan 2023 15:13:33 + (UTC), Mike Baskin declaimed the following: >Can you stop please > Stop what? You appear to be subscribed to the Python mailing list -- as such you WILL receive all traffic that appears on that list. There is nothing we can do. It is not a pers

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

2023-01-24 Thread avi.e.gross
If I understood the issue, the problem is the unary minus at the start of the expression. So if you know the expression is in that argument, would it make sense to pad it in one of many ways that are otherwise harmless? Could you put parens on both sides of "-4^2+5.3*abs(-2-1)/2": "(-4^2+5.3*

Re: bool and int

2023-01-24 Thread Chris Angelico
On Wed, 25 Jan 2023 at 08:22, MRAB wrote: > For backwards compatibility, bool was made a subclass of int. Plus, it's really REALLY handy in quite a lot of situations. > > C# is pickier, which I guess is a good thing. > Nope, not a good thing. Actually a highly frustrating thing on those occasio

Re: bool and int

2023-01-24 Thread MRAB
On 2023-01-24 20:32, Weatherby,Gerard wrote: https://peps.python.org/pep-0285/ From: Python-list on behalf of rbowman Date: Tuesday, January 24, 2023 at 3:01 PM To: python-list@python.org Subject: Re: bool and int bool is a subtype of integer. I never dug that deep into Python's guts but I

Re: bool and int

2023-01-24 Thread Weatherby,Gerard
https://peps.python.org/pep-0285/ From: Python-list on behalf of rbowman Date: Tuesday, January 24, 2023 at 3:01 PM To: python-list@python.org Subject: Re: bool and int bool is a subtype of integer. I never dug that deep into Python's guts but I assume it goes back to boolean being an aftert

Re: bool and int

2023-01-24 Thread Weatherby,Gerard
Booleans work exactly the way the language documentation says they work: Booleans (bool) These represent the truth values False and True. The two objects representing the values False and True are the only Boolean objects. The Boolean type is

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

2023-01-24 Thread Mike Baskin via Python-list
Can you stop please Sent from Yahoo Mail for iPhone On Tuesday, January 24, 2023, 10:12 AM, Thomas Passin wrote: On 1/23/2023 9:12 PM, Chris Angelico wrote: > On Tue, 24 Jan 2023 at 13:09, Jach Feng wrote: >> >> Chris Angelico 在 2023年1月24日 星期二清晨5:00:27 [UTC+8] 的信中寫道: >>> On Tue, 24 Jan 2023

bool and int

2023-01-24 Thread Dino
$ python Python 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> b = True >>> isinstance(b,bool) True >>> isinstance(b,int) True >>> WTF! -- https://mail.python.org/mailman/listinfo/python-list

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

2023-01-24 Thread Mike Baskin via Python-list
Stop please Sent from Yahoo Mail for iPhone On Tuesday, January 24, 2023, 1:05 AM, Cameron Simpson wrote: On 23Jan2023 17:58, Jach Feng wrote: parser.parse_args(['--', 'infix2postfix.py', '-4.3+5']) >usage: [-h] infix >: error: unrecognized arguments: -4.3+5 This error doesn't look lik

Re: bool and int

2023-01-24 Thread rbowman
On Mon, 23 Jan 2023 23:22:00 -0500, Dino wrote: > $ python Python 3.8.10 (default, Mar 15 2022, 12:22:08) > [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" > for more information. > >>> b = True isinstance(b,bool) > True > >>> isinstance(b,int) > True > >>> > >>> > WTF!

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

2023-01-24 Thread Jach Feng
cameron...@gmail.com 在 2023年1月24日 星期二下午2:05:33 [UTC+8] 的信中寫道: > On 23Jan2023 17:58, Jach Feng wrote: > parser.parse_args(['--', 'infix2postfix.py', '-4.3+5']) > >usage: [-h] infix > >: error: unrecognized arguments: -4.3+5 > This error doesn't look like "-4.3+5 looks like an option" but in

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

2023-01-24 Thread Michael Torrie
On 1/23/23 18:58, Jach Feng wrote: > More pathonic, but don't work. The '--' must be at index 1:-) I'm very confused. Why are you even using argparse, since if you put -- at index 1 then argparse wont't do any argument parsing at all. If all you want is the expression on the command line, just a

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

2023-01-24 Thread Weatherby,Gerard
I understand we all want to be helpful and friendly, but it seems to me that helping someone use the wrong tool for the job isn’t really helpful in the long run. argparse is for parsing command line arguments. It’s the wrong tool for this job. As Chris Angelico already said: This entire threa

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

2023-01-24 Thread Thomas Passin
On 1/24/2023 10:13 AM, Mike Baskin wrote: Can you stop please It's way past time, isn't it! Sent from Yahoo Mail for iPhone On Tuesday, January 24, 2023, 10:12 AM, Thomas Passin wrote: On 1/23/2023 9:12 PM, Chris Angelico wrote: > On T

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

2023-01-24 Thread Thomas Passin
On 1/23/2023 9:12 PM, Chris Angelico wrote: On Tue, 24 Jan 2023 at 13:09, Jach Feng wrote: Chris Angelico 在 2023年1月24日 星期二清晨5:00:27 [UTC+8] 的信中寫道: On Tue, 24 Jan 2023 at 07:47, Cameron Simpson wrote: But for Jach Feng: the "--" is really expected as something the user does when they invoke