[Python-ideas] Re: Pre PEP: Python Literals (was custom strings before)

2021-06-13 Thread Jim Baker
Supporting JavaScript-style template literals, specifically tagged templates, could be generally useful. If we look at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates, it's a really simple idea: The tag function is called with the following argu

[Python-ideas] Re: Pre PEP: Python Literals (was custom strings before)

2021-07-05 Thread Jim Baker
JavaScript's tagged template literals do provide nice ergonomics. These should work well with some variation on PEP 501's types.InterpolationTemplate as the backend implementation. Some thoughts on what that should look like: * I also increasingly prefer the idea of using backticks to define such

[Python-ideas] Re: Pre PEP: Python Literals (was custom strings before)

2021-07-05 Thread Jim Baker
On Mon, Jul 5, 2021, 12:56 PM Barry Scott wrote: > > > On 5 Jul 2021, at 08:07, Thomas Güttler wrote: > > This means backticks, but without the dollar sign. > > > In bash the backtick was so often a problem that $(cmd) was added. > > Having removes the grit-on-Tim's-screen backtick in python 3 I

[Python-ideas] Re: Pre PEP: Python Literals (was custom strings before)

2021-07-05 Thread Jim Baker
On Mon, Jul 5, 2021, 2:40 PM Guido van Rossum wrote: > FWIW, we could make f-strings properly nest too, like you are proposing > for backticks. It's just that we'd have to change the lexer. But it would > not be any harder than would be for backticks (since it would be the same > algorithm), nor

[Python-ideas] Re: Pre PEP: Python Literals (was custom strings before)

2021-07-11 Thread Jim Baker
On Thu, Jul 8, 2021 at 6:25 PM Nick Coghlan wrote: > On Tue, 6 Jul 2021, 7:56 am Jim Baker, wrote: > >> >> >> On Mon, Jul 5, 2021, 2:40 PM Guido van Rossum wrote: >> >>> FWIW, we could make f-strings properly nest too, like you are proposing >>

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-23 Thread Jim Baker
Supporting ~ as a binary operator is an interesting idea, especially given the relatively limited usage of unary ~. However, the big hole in this proposal for formulas is that there is a de facto standard "minilanguage" for writing such formulas in Python, namely what Patsy supports: https://patsy.

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Jim Baker
I am no expert on R, but R lazily evaluates arguments to functions; see https://cran.r-project.org/doc/manuals/r-devel/R-lang.html#Argument-evaluation (plus the rest of that page, which is the language spec). Tilde is strictly used for modeling. Also relevant would be the operator precedence https:

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-07 Thread Jim Baker
-1 on this new functionality Referring again to PEP 3106, and its support for views - this was inspired by the functionality seen with java.util.Map. Now that dict is sort of like java.util.LinkedHashMap - albeit safe for concurrent operations* - it's worth exploring if there's anything in the exp

Re: [Python-ideas] Thread-safe generators

2017-04-17 Thread Jim Baker
This is a bad idea in the generator itself, as commented earlier by others here. >From a cross implementation perspective, in Jython, different threads can call next on a non running generator, *so long as they coordinate with each other external to any use of this generator*, and this works fine.

Re: [Python-ideas] Exposing CPython's subinterpreter C-API in the stdlib.

2017-05-25 Thread Jim Baker
Eric, Something like these subinterpreters in CPython are used from Jython's Java API. Like nearly all of Jython* this can be directly imported into using Python code, as seen in tests using this feature: https://github.com/ jythontools/jython/blob/master/Lib/test/test_pythoninterpreter_jy.py Mo

Re: [Python-ideas] Hexadecimal floating literals

2017-09-21 Thread Jim Baker
On Thu, Sep 21, 2017 at 1:57 AM, Paul Moore wrote: > ... > > It's also worth remembering that there will be implementations other > than CPython that will need changes, too - Jython, PyPy, possibly > Cython, and many editors and IDEs. So setting the bar at "someone who > wants this will have to s

Re: [Python-ideas] Hexadecimal floating literals

2017-09-21 Thread Jim Baker
On Thu, Sep 21, 2017 at 7:32 PM, Steven D'Aprano wrote: > On Thu, Sep 21, 2017 at 01:09:11PM -0700, David Mertz wrote: > > -1 > > > > Writing a floating point literal requires A LOT more knowledge than > writing > > a hex integer. > > > > What is the bit length of floats on your specific Python c