[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread Brendan Barnwell
On 2021-04-02 06:48, John wrote: It occurs to me it's a syntax error everywhere to put two potentially-calculable terms in a row with nothing between them, e.g.: Thoughts? My thoughts are: 1) This post is rambling and does not make clear exactly what is being proposed. 2) Python

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread Greg Ewing
On 4/04/21 6:50 am, Chris Angelico wrote: Algebra gives us a HIGHLY compact notation (far too compact to be truly useful in computing, as it's very blackboard/paper oriented) Anyone up for allowing Mathjax in Python source? -- Greg ___ Python-ideas

[Python-ideas] Allow Annotated annotation in dataclass

2021-04-03 Thread brianmarroq
typing.Annotated could be used to build dataclasses. Using Annotated will allow libraries to add functionality to a dataclass without having to change dataclass creation or behavior. The example below shows how a dataclass could be implemented. It continues the example of struct2 shown in

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread Chris Angelico
On Sun, Apr 4, 2021 at 3:17 AM Stephen J. Turnbull wrote: > One practical problem with RPN is that one way to break up and "mark" > subexpressions *without* temporary variables is to use (physical) > newlines and indentation. With infix notation > > (minuend # note: parentheses are

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread Stephen J. Turnbull
John writes: > Here's a question: is it possible to implement this with a Python > module, or is that absolutely not a thing that can be done? Yes, it can, or at least you could use MacroPy (not sure if that's pure Python, if it is then you could implement in a module using the same

[Python-ideas] Re: Access to source code when using exec()

2021-04-03 Thread André Roberge
I don't recall anyone reacting to this idea from Alex Hall. As he mentioned, IPython implements its own way of caching code entered in the REPL. IDLE does as well and uses it when providing traceback. Recently (starting with Python 3.10.0a5), IDLE started exposing such cached content so that

[Python-ideas] Re: str.substring_after and str.substring_before as in Kotlin

2021-04-03 Thread Chris Angelico
On Sun, Apr 4, 2021 at 1:10 AM wrote: > - The best alternative currently is str.partition(sep) but such code is not > very readable, plus most users do not know about it, as proven by the > StackOverflow link. Note that if not found this defaults to the original str > for substringAfter, and

[Python-ideas] str.substring_after and str.substring_before as in Kotlin

2021-04-03 Thread janfrederik . konopka
Dear pythonistas, I would really like having a function like String.substringAfter(sep) and String.substringBefore(sep) as in Kotlin. fun String.substringAfter( delimiter: String, missingDelimiterValue: String = this ): String substringAfter/substringBefore takes a delimiter, and

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread John
Here's a question: is it possible to implement this with a Python module, or is that absolutely not a thing that can be done? I've seen some odd things done with modules. On Sat, Apr 3, 2021 at 8:46 AM John wrote: > > On Sat, Apr 3, 2021 at 5:26 AM Stephen J. Turnbull > wrote: > > > >

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread Richard Damon
On 4/3/21 7:16 AM, Greg Ewing wrote: > On 3/04/21 6:15 pm, David Mertz wrote: >> It's a long time ago, but I'm pretty sure I used ticker tape adding >> machines with a big ENTER button to separate numbers... Then the >> operation, usually +, at the end. > > That seems unlikely. If you don't tell

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread John
On Sat, Apr 3, 2021 at 5:26 AM Stephen J. Turnbull wrote: > > Alexandre Brault writes: > > On 2021-04-03 12:07 a.m., John wrote: > > > >> Visually this means I can identify each particular operation and its > > >> relationship with the next term, then ignore it (visually track parts > > >>

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread John
On Sat, Apr 3, 2021 at 1:03 AM Greg Ewing wrote: > > On 3/04/21 5:07 pm, John wrote: > > This fails when it's like b*((x*2^(3-a))-(7*c)), since > > you now have to look back and forth and get a handle on what each of > > the terms is. b x 2 3 a - ** * 7 c * - * is pretty much a set of > > steps

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread Greg Ewing
On 3/04/21 6:15 pm, David Mertz wrote: It's a long time ago, but I'm pretty sure I used ticker tape adding machines with a big ENTER button to separate numbers... Then the operation, usually +, at the end. That seems unlikely. If you don't tell it what to do with the numbers until the very

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread Stephen J. Turnbull
Alexandre Brault writes: > On 2021-04-03 12:07 a.m., John wrote: > >> Visually this means I can identify each particular operation and its > >> relationship with the next term, then ignore it (visually track parts > >> that no longer matter for understanding the equation) and look at the >

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread Stephen J. Turnbull
Greg Ewing writes: > To get by with just one "+" you would need some way to bracket > the arguments, then you have something more like backwards Lisp > with at least as many parens as infix. You can't invoke Lisp here: (+) 0 (+ 1) 1 (+ 1 1) 2 (+ 1 1 1) 3 and so on. My recollection is the

[Python-ideas] Clarification to PEP 394

2021-04-03 Thread Stephen J. Turnbull
Moving to Python Dev, reply-to set. Please reply to Python-Dev only. Full message appended at end for context. Adam Hendry writes: > Although PEP 394 is geared towards Linux users, those unfamiliar > with Linux don't know what env is or what it does. env(1) is not Linux-specific. It a POSIX

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread Alexandre Brault
On 2021-04-03 12:07 a.m., John wrote: The fundamental point I made up front was that reading the stuff back and auditing it is much more difficult with complex equations in algebraic notation than in postfix. Writing equations is only difficult as a side effect of it being difficult to keep