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

Re: Evaluation of variable as f-string

2023-01-28 Thread Thomas Passin
On 1/28/2023 2:50 PM, Johannes Bauer wrote: Am 28.01.23 um 02:51 schrieb Thomas Passin: This is literally the version I described myself, except using triple quotes. It only modifies the underlying problem, but doesn't solve it. Ok, so now we are in the territory of "Tell us what you are

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

Re: Evaluation of variable as f-string

2023-01-28 Thread Chris Angelico
On Sun, 29 Jan 2023 at 14:36, Stefan Ram wrote: > > Johannes Bauer writes: > >I have a string. I want to evaluate it as if it were an f-string. I.e., > >there *are* obviously restrictions that apply (namely, the syntax and > >semantics of f-strings), but that's it. > > (This message was

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

2023-01-28 Thread avi.e.gross
Jack, I get uneasy when someone thinks a jackhammer is a handy dandy tool for pushing in a thumbtack that is sitting on my expensive table. I agree it is quite easy to grab some code that does lot of things and also does something truly minor, and use it for that purpose. Sometimes the cost is

Re: Usenet vs. Mailing-list

2023-01-28 Thread Ben Bacarisse
Jon Ribbens writes: > On 2023-01-29, Ben Bacarisse wrote: >> "Peter J. Holzer" writes: >> >>> On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: mutt...@dastardlyhq.com writes: > Hi It looks like you posted this question via Usenet. comp.lang.python is

Re: Usenet vs. Mailing-list

2023-01-28 Thread Jon Ribbens via Python-list
On 2023-01-29, Ben Bacarisse wrote: > "Peter J. Holzer" writes: > >> On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: >>> mutt...@dastardlyhq.com writes: >>> >>> > Hi >>> >>> It looks like you posted this question via Usenet. comp.lang.python is >>> essentially dead as a Usenet group. It

Re: Usenet vs. Mailing-list

2023-01-28 Thread Ben Bacarisse
"Peter J. Holzer" writes: > On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: >> mutt...@dastardlyhq.com writes: >> >> > Hi >> >> It looks like you posted this question via Usenet. comp.lang.python is >> essentially dead as a Usenet group. It exists, and gets NNTP versions >> of mail sent

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" > >> usage: infix2postfix.py [-h] [infix] > >> infix2postfix.py:

Re: Usenet vs. Mailing-list

2023-01-28 Thread Chris Angelico
On Sun, 29 Jan 2023 at 12:07, Chris Green wrote: > > Chris Green wrote: > > Jon Ribbens wrote: > > > On 2023-01-28, Peter J. Holzer wrote: > > > > On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: > > > >> It looks like you posted this question via Usenet. comp.lang.python is > > > >>

Re: Evaluation of variable as f-string

2023-01-28 Thread Chris Angelico
On Sun, 29 Jan 2023 at 11:56, Johannes Bauer wrote: > > Am 28.01.23 um 00:41 schrieb Chris Angelico: > > On Sat, 28 Jan 2023 at 10:08, Rob Cliffe via Python-list > > wrote: > >> > >> Whoa! Whoa! Whoa! > >> I appreciate the points you are making, Chris, but I am a bit taken > >> aback by such

Re: bool and int

2023-01-28 Thread Chris Angelico
On Sun, 29 Jan 2023 at 11:27, rbowman wrote: > > On Fri, 27 Jan 2023 21:35:11 -0800 (PST), Grant Edwards wrote: > > > In Unix shells, a return code of 0 is true and non-0 is false. > > That carries over to some C functions like strcmp() although it's more > complex. strcmp() returns the value of

Re: Usenet vs. Mailing-list

2023-01-28 Thread Dennis Lee Bieber
On Sat, 28 Jan 2023 20:07:44 +, Chris Green declaimed the following: >As far as I am aware the mirroring of the Python mailing list on >comp.lan.python works perfectly. I love gmane! :-) Is gmane's gmane.comp.python.general allowing posts to go through again? I had to revert to

Re: Usenet vs. Mailing-list

2023-01-28 Thread Chris Green
Chris Green wrote: > Jon Ribbens wrote: > > On 2023-01-28, Peter J. Holzer wrote: > > > On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: > > >> It looks like you posted this question via Usenet. comp.lang.python is > > >> essentially dead as a Usenet group. It exists, and gets NNTP versions

Re: Evaluation of variable as f-string

2023-01-28 Thread Chris Angelico
On Sun, 29 Jan 2023 at 11:53, Johannes Bauer wrote: > I don't want to have to care about what quotation is used inside the > string, as long as it could successfully evaluate using the f-string > grammar. > Not possible. An f-string can contain other f-strings, and it is entirely possible to use

Re: Usenet vs. Mailing-list

2023-01-28 Thread Chris Green
Jon Ribbens wrote: > On 2023-01-28, Peter J. Holzer wrote: > > On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: > >> It looks like you posted this question via Usenet. comp.lang.python is > >> essentially dead as a Usenet group. It exists, and gets NNTP versions > >> of mail sent to the

Re: Evaluation of variable as f-string

2023-01-28 Thread Johannes Bauer
Am 27.01.23 um 23:10 schrieb Christian Gollwitzer: Am 27.01.23 um 21:43 schrieb Johannes Bauer: I don't understand why you fully ignore literally the FIRST example I gave in my original post and angrily claim that you solution works when it does not: x = { "y": "z" } s = "-> {x['y']}"

Re: Evaluation of variable as f-string

2023-01-28 Thread Johannes Bauer
Am 28.01.23 um 00:41 schrieb Chris Angelico: On Sat, 28 Jan 2023 at 10:08, Rob Cliffe via Python-list wrote: Whoa! Whoa! Whoa! I appreciate the points you are making, Chris, but I am a bit taken aback by such forceful language. The exact same points have already been made, but not listened

Re: Evaluation of variable as f-string

2023-01-28 Thread Johannes Bauer
Am 28.01.23 um 02:51 schrieb Thomas Passin: This is literally the version I described myself, except using triple quotes. It only modifies the underlying problem, but doesn't solve it. Ok, so now we are in the territory of "Tell us what you are trying to accomplish". And part of that is why

Re: Usenet vs. Mailing-list (was: evaluation question)

2023-01-28 Thread Jon Ribbens via Python-list
On 2023-01-28, Peter J. Holzer wrote: > On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: >> It looks like you posted this question via Usenet. comp.lang.python is >> essentially dead as a Usenet group. It exists, and gets NNTP versions >> of mail sent to the mailing list, but nothing posted

Re: evaluation question

2023-01-28 Thread Mark Bourne
mutt...@dastardlyhq.com wrote: On Sat, 28 Jan 2023 14:22:01 +1300 dn wrote: Do you know about the Python REPL? Haven't learnt the acronyms yet. REPL stands for "Read Evaluate Print Loop". It basically refers to the interactive interpreter, which reads input you type, evaluates it,

Re: evaluation question

2023-01-28 Thread Louis Krupp
On 1/27/2023 9:37 AM, mutt...@dastardlyhq.com wrote: Hi This is probably a dumb newbie question but I've just started to learn python3 and eval() isn't behaving as I'd expect in that it works for some things and not others. eg: eval("1+1") 2 eval("print(123)") 123 eval("for i in

Re: evaluation question

2023-01-28 Thread Muttley
On Sat, 28 Jan 2023 14:22:01 +1300 dn wrote: >On 28/01/2023 05.37, mutt...@dastardlyhq.com wrote: >> This is probably a dumb newbie question but I've just started to learn >> python3 and eval() isn't behaving as I'd expect in that it works for >> some things and not others. eg: >> >

Re: evaluation question

2023-01-28 Thread Muttley
On Fri, 27 Jan 2023 21:04:58 + Ben Bacarisse wrote: >mutt...@dastardlyhq.com writes: > >> Hi > >It looks like you posted this question via Usenet. comp.lang.python is >essentially dead as a Usenet group. It exists, and gets NNTP versions >of mail sent to the mailing list, but nothing posted

Re: Usenet vs. Mailing-list (was: evaluation question)

2023-01-28 Thread Dennis Lee Bieber
On Sat, 28 Jan 2023 15:30:59 +0100, "Peter J. Holzer" declaimed the following: >On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: >> mutt...@dastardlyhq.com writes: >> >> > Hi >> >> It looks like you posted this question via Usenet. comp.lang.python is >> essentially dead as a Usenet group.

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 > > Also fail in REPL, > >

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,

Re: RE: RE: bool and int

2023-01-28 Thread Dino
you have your reasons, and I was tempted to stop there, but... I have to pick this... On 1/26/2023 10:09 PM, avi.e.gr...@gmail.com wrote: You can often borrow ideas and code from an online search and hopefully cobble "a" solution together that works well enough. Of course it may suddenly

Re: bool and int

2023-01-28 Thread rbowman
On Fri, 27 Jan 2023 21:35:11 -0800 (PST), Grant Edwards wrote: > In Unix shells, a return code of 0 is true and non-0 is false. That carries over to some C functions like strcmp() although it's more complex. strcmp() returns the value of subtracting the nth character of string b from string a

Re: logically Boolean

2023-01-28 Thread dn via Python-list
On 29/01/2023 09.28, Chris Angelico wrote: The REAL boolean is the friends we made along the way? By REAL did you mean float - True or False? (for the FORTRAN-free: https://fortranwiki.org/fortran/show/real) -- -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list

Re: logically Boolean

2023-01-28 Thread Chris Angelico
On Sun, 29 Jan 2023 at 04:33, wrote: > The right answer is that the question is too simple. It is what YOU want it > to be in your situation. And it is also what the LANGUAGE designers and > implementers have chosen within their domain. The REAL boolean is the friends we made along the way?

Non int Boolean

2023-01-28 Thread Weatherby,Gerard
If someone really really wants a non-int Boolean, it is easy to implement. 5 or 6 lines, depending on whether you count the import statement: from enum import Enum class MyBool(Enum): TRUE = 42 FALSE = 54 def __bool__(self): return self == MyBool.TRUE # # testing #

Unix / linux programs

2023-01-28 Thread Weatherby,Gerard
The Unix convention is 0 means everything went well, and non-zero means something else happened. Here’s a contrived example of a bash wrapper around GNU tar. By contrived I mean it works but I would not use it in practice … I’d just use tar directly or use the Python tarfile module if I wanted

logically Boolean

2023-01-28 Thread avi.e.gross
The topic has somewhat modified to asking what is a BOOLEAN. The right answer is that the question is too simple. It is what YOU want it to be in your situation. And it is also what the LANGUAGE designers and implementers have chosen within their domain. Mathematically, as part of

Usenet vs. Mailing-list (was: evaluation question)

2023-01-28 Thread Peter J. Holzer
On 2023-01-27 21:04:58 +, Ben Bacarisse wrote: > mutt...@dastardlyhq.com writes: > > > Hi > > It looks like you posted this question via Usenet. comp.lang.python is > essentially dead as a Usenet group. It exists, and gets NNTP versions > of mail sent to the mailing list, but nothing

Re: Evaluation of variable as f-string

2023-01-28 Thread Peter J. Holzer
On 2023-01-27 21:31:05 +0100, Johannes Bauer wrote: > > But if you really REALLY know what you're doing, just use eval() > > directly. > > I do, actually, but I hate it. Not because of the security issue, not > because of namespaces, but because it does not reliably work: > > >>> s = "{\"x\" *

Re: Evaluation of variable as f-string

2023-01-28 Thread Peter J. Holzer
On 2023-01-27 21:43:09 +0100, Johannes Bauer wrote: > x = { "y": "z" } > s = "-> {x['y']}" > print(s.format(x = x)) > Traceback (most recent call last): > File "", line 1, in > KeyError: "'y'" > > This. Does. Not. Work. > > I want to pass a single variable as a dictionary and access its

Re: Evaluation of variable as f-string

2023-01-28 Thread Peter J. Holzer
On 2023-01-27 20:56:49 -0500, Thomas Passin wrote: > On 1/27/2023 5:10 PM, Christian Gollwitzer wrote: > > Am 27.01.23 um 21:43 schrieb Johannes Bauer: > > > x = { "y": "z" } > > > s = "-> {x['y']}" > > > print(s.format(x = x)) > > > Traceback (most recent call last): > > >    File "", line 1, in