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

2023-01-29 Thread Cameron Simpson
On 29Jan2023 08:10, avi.e.gr...@gmail.com wrote: You are technically correct but perhaps off the mark. Yes, a python program only sees what is handed to it by some shell if invoked a certain way. The issue here is what you tell people using your program about what they need to type to get it

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

2023-01-29 Thread Cameron Simpson
On 29Jan2023 07:12, 2qdxy4rzwzuui...@potatochowder.com <2qdxy4rzwzuui...@potatochowder.com> wrote: On 2023-01-29 at 16:51:20 +1100, Cameron Simpson wrote: They're unrelated. As others have mentioned, "--" is _extremely_ common; almost _all_ UNIX command like programmes which handle -* style o

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

2023-01-29 Thread Ethan Furman
This thread has run its course and seems to now be generating more heat than light. It is now closed (at least on the Python List side). Thank you everyone for your participation and understanding. -- ~Ethan~ Moderator -- 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-29 Thread Mark Bourne
Jach Feng wrote: Thank you for detail explanation of the role the shell is involved in this problem. I'm very appreciated! It seems that a CLI app may become very complex when dealing with different kind of shell, and may not be possible to solve its problem. But the good thing in my app is t

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

2023-01-29 Thread Mark Bourne
Jach Feng wrote: 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:

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

2023-01-29 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 > >

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

2023-01-29 Thread Peter J. Holzer
On 2023-01-27 21:03:39 -0800, Jach Feng wrote: > I have to admit that I don't know the background upon which the > argparse was built. The good side is that I don't carry its historical > knowledge ( or burden?), that's why I can use it in a new way I don't see what's new about that. > which may

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

2023-01-29 Thread Peter J. Holzer
On 2023-01-29 07:59:21 -0500, avi.e.gr...@gmail.com wrote: > Although today you could say POSIX is the reason for many things including > the use of "--" I hesitate to mention I and many others used that convention > long before as a standard part of many UNIX utilities. I somewhat doubt that you

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

2023-01-29 Thread avi.e.gross
"--" ... -Original Message- From: Python-list On Behalf Of Cameron Simpson Sent: Sunday, January 29, 2023 12:51 AM To: python-list@python.org Subject: Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument? On 28Jan2023 18:55, Jach Feng wrote: >Mark Bour

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

2023-01-29 Thread avi.e.gross
tandardize, ... -Original Message- From: Python-list On Behalf Of 2qdxy4rzwzuui...@potatochowder.com Sent: Sunday, January 29, 2023 7:12 AM To: python-list@python.org Subject: Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument? On 2023-01-29 at 16:51:20 +1100, Ca

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

2023-01-29 Thread 2QdxY4RzWzUUiLuE
On 2023-01-29 at 16:51:20 +1100, Cameron Simpson wrote: > They're unrelated. As others have mentioned, "--" is _extremely_ common; > almost _all_ UNIX command like programmes which handle -* style options > honour the "--" convention. _argparse_ itself honours that convention, as > does getopt et

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

2023-01-28 Thread Cameron Simpson
On 28Jan2023 18:55, Jach Feng wrote: Mark Bourne 在 2023年1月28日 星期六晚上10:00:01 [UTC+8] 的信中寫道: I notice you explain the need to enclose the equation in quotes if it contains spaces. That's not even a feature of your application, but of the shell used to call it. So why so much objection to explaini

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

2023-01-28 Thread Chris Angelico
On Sun, 29 Jan 2023 at 14:29, Jach Feng wrote: > Thank you for detail explanation of the role the shell is involved in this > problem. I'm very appreciated! > > It seems that a CLI app may become very complex when dealing with different > kind of shell, and may not be possible to solve its probl

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

2023-01-28 Thread avi.e.gross
to do what you want. -Original Message- From: Python-list On Behalf Of Jach Feng Sent: Saturday, January 28, 2023 12:04 AM To: python-list@python.org Subject: Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument? Jach Feng 在 2023年1月22日 星期日上午11:11:22 [UTC+8]

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

2023-01-28 Thread Jach Feng
Mark Bourne 在 2023年1月28日 星期六晚上10:00:01 [UTC+8] 的信中寫道: > Jach Feng wrote: > > 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" > >> u

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

2023-01-28 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 > >

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

2023-01-28 Thread Mark Bourne
Jach Feng wrote: 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:

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

2023-01-27 Thread Michael Torrie
On 1/25/23 19:50, Jach Feng wrote: > To me, argparse has been just a tool which I can use in a CLI app. argparse is just a tool for dealing with command-line *flags*, which are common in command-line tools. argparse interprets the command line as a bunch of flags because that's what it's designe

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

2023-01-26 Thread Mats Wichmann
On 1/24/23 23:28, Jach Feng wrote: Chris Angelico 在 2023年1月25日 星期三下午1:16:25 [UTC+8] 的信中寫道: 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

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

2023-01-25 Thread Chris Angelico
On Thu, 26 Jan 2023 at 14:13, Jach Feng wrote: > Now I understand some oppose this idea and saying that you shouldn't use a > kitchen knife to cut a cake:-) You shouldn't use a chainsaw to cut a cake, and then ask us why cake-cutting is so noisy. ChrisA -- https://mail.python.org/mailman/listi

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

2023-01-25 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 > >

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

2023-01-25 Thread David
On Thu, 26 Jan 2023 at 04:24, Jach Feng wrote: > Chris Angelico 在 2023年1月25日 星期三下午1:16:25 [UTC+8] 的信中寫道: > > On Wed, 25 Jan 2023 at 14:42, Jach Feng 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

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

2023-01-25 Thread Weatherby,Gerard
ult, controlling the number of arguments and the like. From: Python-list on behalf of Jach Feng Date: Wednesday, January 25, 2023 at 12:25 PM To: python-list@python.org Subject: Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument? *** Attention: This is an external

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

2023-01-25 Thread Chris Angelico
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 = argparse.ArgumentParser(description='Convert infix notation to &

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

2023-01-25 Thread Jach Feng
Chris Angelico 在 2023年1月25日 星期三下午1:16:25 [UTC+8] 的信中寫道: > 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

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

2023-01-24 Thread Cameron Simpson
you have many options to handle? 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 = argparse.ArgumentParser(description='Convert infix notation to postfix') parser.add_argument('infix', n

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

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 > >

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

2023-01-24 Thread Jach Feng
erwise harmless? > > Could you put parens on both sides of "-4^2+5.3*abs(-2-1)/2": > > "(-4^2+5.3*abs(-2-1)/2)" > > Or perhaps place a zero in front as in the awkward case where it begins with > a minus sign: > > "0 -4^2+5.3*abs(-2-1)/2" &

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: 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":

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
an argument. So the user is expected to type: >>>> >>>> your_script -x -y -- "-4^2+5.3*abs(-2-1)/2" >>>> >>>> where there are -x and -y options, then end of options, then an >>>> argument, which would look like an option if the

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: 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
thread is a massive "how can I use X to do Y?" problem. From: Python-list on behalf of Thomas Passin Date: Tuesday, January 24, 2023 at 10:23 AM To: Mike Baskin , python-list@python.org Subject: Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument? *** A

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

2023-01-24 Thread Thomas Passin
>>>> >>>> But for Jach Feng: the "--" is really expected as something the user >>>> does when they invoke your programme, _explicitly_ saying that what >>>> follows from here is not an argument. So the user is expected t

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

2023-01-24 Thread Thomas Passin
when they invoke your programme, _explicitly_ saying that what follows from here is not an argument. So the user is expected to type: your_script -x -y -- "-4^2+5.3*abs(-2-1)/2" where there are -x and -y options, then end of options, then an argument, which would look like an option

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

2023-01-23 Thread Cameron Simpson
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 instead "we don't expect any arguments after "infix". Not personally a fan o

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

2023-01-23 Thread Jach Feng
Greg Ewing 在 2023年1月24日 星期二清晨7:33:43 [UTC+8] 的信中寫道: > >> On 2023-01-22 at 18:19:13 -0800, > >> Jach Feng 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 t

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

2023-01-23 Thread Chris Angelico
t; > > does when they invoke your programme, _explicitly_ saying that what > > > follows from here is not an argument. So the user is expected to type: > > > > > > your_script -x -y -- "-4^2+5.3*abs(-2-1)/2" > > > > > > where there are -x and -y o

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

2023-01-23 Thread Jach Feng
> > follows from here is not an argument. So the user is expected to type: > > > > your_script -x -y -- "-4^2+5.3*abs(-2-1)/2" > > > > where there are -x and -y options, then end of options, then an > > argument, which would look like an option if the

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

2023-01-23 Thread Jach Feng
tual arguments) will work until your > program actually has options. > > 2) By adding an extra space character before the leading '-' sign, ie. > > e:\Works\Python>py infix2postfix.py " -4^2+5.3*abs(-2-1)/2" > > -4 2 ^ 5.3 -2 1 - abs * 2 / + > >

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

2023-01-23 Thread Greg Ewing
On 2023-01-22 at 18:19:13 -0800, Jach Feng 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 ar

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

2023-01-23 Thread Chris Angelico
> your_script -x -y -- "-4^2+5.3*abs(-2-1)/2" > > where there are -x and -y options, then end of options, then an > argument, which would look like an option if there wasn't the "--" > argument. And if you DON'T expect the user to enter the &qu

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

2023-01-23 Thread Cameron Simpson
er does when they invoke your programme, _explicitly_ saying that what follows from here is not an argument. So the user is expected to type: your_script -x -y -- "-4^2+5.3*abs(-2-1)/2" where there are -x and -y options, then end of options, then an argument, which would look like

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

2023-01-23 Thread 2QdxY4RzWzUUiLuE
ign, ie. > e:\Works\Python>py infix2postfix.py " -4^2+5.3*abs(-2-1)/2" > -4 2 ^ 5.3 -2 1 - abs * 2 / + > > But no idea how it works? and if it can survive in a newer argparse > version?:-) It works because argparse checks the first character of each argument, a

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

2023-01-23 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 > >

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

2023-01-23 Thread Grant Edwards
On 2023-01-22, Weatherby,Gerard wrote: > Argparse is for parsing command line arguments and options. > > If you just want to evaluate an Python expression, use eval( ) Only use eval() if the expression is always under your control (and you don't make mistakes when typing). Don't use eval() on st

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

2023-01-22 Thread Michael Torrie
On 1/22/23 11:44, Stefan Ram wrote: > Jach Feng 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 > work

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

2023-01-22 Thread Cameron Simpson
On 21Jan2023 19:11, Jach Feng wrote: 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 The usual convention for having "nonoption&qu

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

2023-01-22 Thread Weatherby,Gerard
Argparse is for parsing command line arguments and options. If you just want to evaluate an Python expression, use eval( ) Your string isn’t valid Python due to order of operations, but -(4^2)+5.3*abs(-2-1)/2 is. From: Python-list on behalf of Jach Feng Date: Sunday, January 22, 2023 at 11

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

2023-01-22 Thread Thomas Passin
On 1/22/2023 10:45 AM, Peter J. Holzer wrote: Notice that this file is in its first release, version 0.0.1 - the metadata that says it's 'Development Status :: 5 - Production/Stable' seems to be bogus. So it may very well be buggy. It is at least too incomplete to be useful. It handles only sin

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

2023-01-22 Thread Mark Bourne
Jach Feng wrote: 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,

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

2023-01-22 Thread Jach Feng
Thomas Passin 在 2023年1月22日 星期日下午1:30:39 [UTC+8] 的信中寫道: > On 1/21/2023 10:11 PM, Jach Feng wrote: > > Fail on command line, > > > > e:\Works\Python>py infix2postfix.py "-4^2+5.3*abs(-2-1)/2" > > usage: infix2postfix.py [-h] [infix] > > infix2postf

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

2023-01-22 Thread Peter J. Holzer
On 2023-01-22 00:30:07 -0500, Thomas Passin wrote: > On 1/21/2023 10:11 PM, Jach Feng wrote: > > 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*

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

2023-01-21 Thread Thomas Passin
On 1/21/2023 10:11 PM, Jach Feng wrote: 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.

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

2023-01-21 Thread Jach Feng
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

XanaNews Statistic for comp.lang.python. 8/1/2020 7:48:48 AM [1/2]

2020-08-01 Thread The Doctor via Python-list
16 Fwd: [BUG] missing ')' causes syntax error on next line 414 Iterators, iterables and special objects 512 frozendict: an experiment 611 Symlinks already present 710 Questioning the effects of multiple assignment 8

Re: "1,+2,", but not "(1,)+2,"

2020-07-31 Thread Chris Angelico
On Sat, Aug 1, 2020 at 4:31 AM Jon Ribbens via Python-list wrote: > > On 2020-07-31, Bart wrote: > > Not sure about the trailing commas on each. It seems Python ignores > > trailing commas on tuple constructors, so that the A,B, would be a > > 2-tuple, and A+B, would have been a 1-tuple if A+B ha

Re: "1,+2,", but not "(1,)+2,"

2020-07-31 Thread Jon Ribbens via Python-list
On 2020-07-31, Bart wrote: > Not sure about the trailing commas on each. It seems Python ignores > trailing commas on tuple constructors, so that the A,B, would be a > 2-tuple, and A+B, would have been a 1-tuple if A+B had been legal. It's not just tuples, it's lists, sets, dictionaries, etc. I

Re: "1,+2,", but not "(1,)+2,"

2020-07-31 Thread Python
Stefan Ram wrote: Jon Ribbens writes: On 2020-07-31, Stefan Ram wrote: You can write |>>> 1,+2, |(1, 2) , but not |>>> (1,)+2, |TypeError: can only concatenate tuple (not "int") to tuple . Why? (Python 3.9) For the obvious reason, as indicated by the

Re: "1,+2,", but not "(1,)+2,"

2020-07-31 Thread MRAB
On 2020-07-31 14:15, Jon Ribbens via Python-list wrote: On 2020-07-31, Stefan Ram wrote: You can write |>>> 1,+2, |(1, 2) , but not |>>> (1,)+2, |TypeError: can only concatenate tuple (not "int") to tuple . Why? (Python 3.9) For the obvious reason, as in

Re: "1,+2,", but not "(1,)+2,"

2020-07-31 Thread Jon Ribbens via Python-list
On 2020-07-31, Stefan Ram wrote: > You can write > >|>>> 1,+2, >|(1, 2) > > , but not > >|>>> (1,)+2, >|TypeError: can only concatenate tuple (not "int") to tuple > > . Why? (Python 3.9) For the obvious reason, as indicated by th

Re: Basic Lotus 1-2-3 worksheet creation class for Python

2017-09-15 Thread geoffrey . eisenbarth
I just wanted to let you now that as someone whose boss prefers to use WK1 in 2017, this is going to save my life. Thanks :) About to try this out, if I have to do anything to get it to work with Python3 I'll post the changes here later. -- https://mail.python.org/mailman/listinfo/python-list

Re: Deviding N(1, 2, 3, .., N) part from numeric list as summation of each values(don't sorted) has highest as possible.

2016-10-10 Thread Steve D'Aprano
On Tue, 11 Oct 2016 12:38 am, amornsak@gmail.com wrote: > I have a list is > > land = [10,20,30,40,110,50,18,32,5] > > and I want to find each values of summation (don't sorted values in list) > as It has highest as possible > > example. > > I want to dividing N=3 part from list as above a

Re: Deviding N(1, 2, 3, .., N) part from numeric list as summation of each values(don't sorted) has highest possible.

2016-10-10 Thread Ben Bacarisse
Nune9 writes: > I have a list is > > land = [10,20,30,40,110,50,18,32,5] > > and I want to find each values of summation (don't sorted values in > list) as It has highest possible > > example. > > I want to dividing N=3 part from list as above and divieded each part > has highest values that as p

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-27 Thread Emile van Sebille
On 8/26/2015 2:14 PM, Grant Edwards wrote: On 2015-08-26, Emile van Sebille wrote: On 8/26/2015 9:06 AM, Grant Edwards wrote: It's also unfortunate that there's no way to to access the mailing list via an NNTP server Huh? -- gmane.comp.python.general at news://nntp.gmane.com:119/gmane.comp.p

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Ian Kelly
On Wed, Aug 26, 2015 at 12:11 PM, Andy Kubiak wrote: > What if you could send all your mail to another address on a server you > control, or can at least run programs on? That seems like a lot more hassle than it would be worth. -- https://mail.python.org/mailman/listinfo/python-list

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Grant Edwards
On 2015-08-26, Emile van Sebille wrote: > On 8/26/2015 9:06 AM, Grant Edwards wrote: >> It's also unfortunate that there's no way to >> to access the mailing list via an NNTP server > > Huh? -- gmane.comp.python.general at > news://nntp.gmane.com:119/gmane.comp.python.general > > Or do you mean by

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Emile van Sebille
On 8/26/2015 9:06 AM, Grant Edwards wrote: It's also unfortunate that there's no way to to access the mailing list via an NNTP server Huh? -- gmane.comp.python.general at news://nntp.gmane.com:119/gmane.comp.python.general Or do you mean by the OP? Emile -- https://mail.python.org/mailman/l

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Andy Kubiak
> > I wish I could, problem is, if the mail recipient is within the company, > no legal boilerplate is added making the joke fall flat. > What if you could send all your mail to another address on a server you control, or can at least run programs on? Could you configure all your outgoing mail to

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Jean-Michel Pichavant
- Original Message - > From: "Chris Angelico" > Cc: python-list@python.org > Sent: Wednesday, 26 August, 2015 6:11:51 PM > Subject: Re: Please don't make unfounded legalistic demands (was: [a, b, c, > d] = 1, 2, 3, 4) > > On Thu, Aug 27, 2015 at 1:

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Chris Angelico
On Thu, Aug 27, 2015 at 1:09 AM, Terry Reedy wrote: > How about instead you augment your signature with "Please ignore the > boilerplate below. Heh, I like this! Or: """ -- BOILERPLATE TROPHY COLLECTION I am a collector of stupid legal boilerplate. Here's my latest acquisition: """ Then let yo

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Grant Edwards
On 2015-08-26, Terry Reedy wrote: > On 8/26/2015 5:02 AM, Jean-Michel Pichavant wrote: >>> Misleading, intimidating, hostile nonsense. > > Agreed. > >>> If you want to participate here, please do so from a mail system > >> which does not make these legalistic demands. > > I disagree with prohibit

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Gene Heskett
On Wednesday 26 August 2015 11:09:18 Terry Reedy wrote: > On 8/26/2015 5:02 AM, Jean-Michel Pichavant wrote: > > - Original Message - > > > >> From: "Ben Finney" > >> > >>> The contents of this email and any attachments are confidential > >>> and may also be privileged. If you are not the

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Terry Reedy
On 8/26/2015 5:02 AM, Jean-Michel Pichavant wrote: - Original Message - From: "Ben Finney" The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the con

Re: Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Jean-Michel Pichavant
- Original Message - > From: "Ben Finney" > > The contents of this email and any attachments are confidential and > > may also be privileged. If you are not the intended recipient, > > please > > notify the sender immediately and do not disclose the contents to > > any > > other person, us

Please don't make unfounded legalistic demands (was: [a, b, c, d] = 1, 2, 3, 4)

2015-08-26 Thread Ben Finney
Jean-Michel Pichavant writes: > -- IMPORTANT NOTICE: > > The contents of this email and any attachments are confidential and > may also be privileged. If you are not the intended recipient, please > notify the sender immediately and do not disclose the contents to any > other person, use it for

Re: Could you explain "[1, 2, 3].remove(2)" to me?

2015-06-25 Thread Jussi Piitulainen
fl writes: > aa=[1, 2, 3].remove(2) > > I don't know where the result goes. Could you help me on the question? That method modifies the list and returns None (or raises an exception). Get a hold on the list first: aa=[1, 2, 3] *Then* call the method. Just call the method, do no

Re: Could you explain "[1, 2, 3].remove(2)" to me?

2015-06-25 Thread Ian Kelly
On Thu, Jun 25, 2015 at 12:14 PM, fl wrote: > Hi, > > I see a code snippet online: > > [1, 2, 3].remove(42) I don't know where you pulled this from, but if this is from a tutorial then it doesn't seem to be a very good one. This constructs a list containing the

Could you explain "[1, 2, 3].remove(2)" to me?

2015-06-25 Thread fl
Hi, I see a code snippet online: [1, 2, 3].remove(42) after I modify it to: [1, 2, 3].remove(2) and aa=[1, 2, 3].remove(2) I don't know where the result goes. Could you help me on the question? Thanks, -- https://mail.python.org/mailman/listinfo/python-list

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-04-02 Thread Dan Sommers
On Mon, 01 Apr 2013 21:45:30 -0700, Tim Roberts wrote: > morphex wrote: >> >>While we're on the subject, wouldn't it be nice to have some cap there >>so that it isn't possible to more or less block the system with large >>exponentiation? > > There IS a cap. It's called the "MemoryError" excepti

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-04-02 Thread Nobody
On Mon, 01 Apr 2013 00:39:56 +, Alex wrote: > Given that > > 3 > 5 > 4 > > (i.e.: 4**5**3) is transitive, I think you meant "associative", and exponentiation isn't associative, i.e. (x**y)**z is not, in general, equal to x**(y**z). In fact, (x**y)**z is equal to x**(y*z). Conventional m

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-04-01 Thread Chris Angelico
On Tue, Apr 2, 2013 at 3:45 PM, Tim Roberts wrote: > morphex wrote: >> >>While we're on the subject, wouldn't it be nice to have some cap there so >>that it isn't possible to more or less block the system with large >>exponentiation? > > There IS a cap. It's called the "MemoryError" exception. >

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-04-01 Thread Tim Roberts
morphex wrote: > >While we're on the subject, wouldn't it be nice to have some cap there so >that it isn't possible to more or less block the system with large >exponentiation? There IS a cap. It's called the "MemoryError" exception. But, seriously, what would you have it do instead? -- Tim R

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-04-01 Thread Roy Smith
In article <51590a2b$0$3$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Concrete examples of transitive relations: greater than, equal to, less > than and equal to. Will Python 4 implement "less than and equal to"? :-) [Warning: topic creep] Well, they are transitive over

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Steven D'Aprano
On Mon, 01 Apr 2013 00:39:56 +, Alex wrote: > Chris Angelico wrote: > > >> Opening paragraph, "... exponentiation, which groups from right to >> left". It follows the obvious expectation from mathematics. (The OP is >> using Python 2, but the same applies.) > > Thanks. I did miss that paren

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Chris Angelico
On Mon, Apr 1, 2013 at 11:39 AM, Alex wrote: > Given that > > 3 > 5 > 4 > > (i.e.: 4**5**3) is transitive, I would have expected Python to exhibit > more consistency with the other operators. I guess that is one of the > foolish consistencies that comprise the hobgoblins of my little mind, > th

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Alex
Chris Angelico wrote: > > Opening paragraph, "... exponentiation, which groups from right to > left". It follows the obvious expectation from mathematics. (The OP is > using Python 2, but the same applies.) Thanks. I did miss that parenthetical comment in para 6.15, and that would have been the

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Dave Angel
On 03/31/2013 06:06 PM, Alex wrote: Dave Angel wrote: On 03/31/2013 02:56 AM, morphex wrote: 1**2 1 1**2**3 1 1**2**3**4 1L 1**2**3**4**5 Traceback (most recent call last): File "", line 1, in MemoryError Does anyone know why this raises a MemoryError? Doesn't m

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Chris Angelico
On Mon, Apr 1, 2013 at 9:28 AM, Chris Angelico wrote: > On Mon, Apr 1, 2013 at 9:06 AM, Alex wrote: >> Really? >> >> The Python 3 documentation >> (http://docs.python.org/3/reference/expressions.html) says in section >> 6.14 (Evaluation order) that "Python evaluates expressions from left to >> ri

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Chris Angelico
On Mon, Apr 1, 2013 at 9:06 AM, Alex wrote: > Dave Angel wrote: > >> On 03/31/2013 02:56 AM, morphex wrote: >> > > > > 1**2 >> > 1 >> > > > > 1**2**3 >> > 1 >> > > > > 1**2**3**4 >> > 1L >> > &g

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Alex
Dave Angel wrote: > On 03/31/2013 02:56 AM, morphex wrote: > > > > > 1**2 > > 1 > > > > > 1**2**3 > > 1 > > > > > 1**2**3**4 > > 1L > > > > > 1**2**3**4**5 > > Traceback (most recent call last): > >

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Jason Swails
On Sun, Mar 31, 2013 at 9:15 AM, Roy Smith wrote: > > > $ prtstat 29937 > > Process: mongodState: S (sleeping) > > [...] > > Memory > > Vsize: 1998285 MB > > RSS: 5428 MB > > RSS Limit: 18446744073709 MB > > If I counted the digits right, that 1.9 TB. I love the R

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Roy Smith
In article , Dave Angel wrote: > I'm typing this while a terminal is open doing the particular operation, > and the system doesn't seem in the least sluggish. > > Currently the memory used is at 10gig, and while there are some pauses > in my typing, the system has not died. This is on Linux

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Roy Smith
In article <8276eff6-9e5c-4060-b9e8-94fab6062...@googlegroups.com>, morphex wrote: > Aha, OK. Thought I found a bug but yeah that makes sense ;) > > While we're on the subject, wouldn't it be nice to have some cap there so > that it isn't possible to more or less block the system with large

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Roy Smith
In article <5157e6cc$0$29974$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > For what it's worth, that last intermediate result (two to the power of > the 489-digit number) has approximately a billion trillion trillion > trillion trillion trillion trillion trillion trillion trill

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-03-31 Thread Dave Angel
On 03/31/2013 08:07 AM, morphex wrote: Aha, OK. Thought I found a bug but yeah that makes sense ;) While we're on the subject, wouldn't it be nice to have some cap there so that it isn't possible to more or less block the system with large exponentiation? There's an assumption there. The O

  1   2   >