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

2021-06-10 Thread Thomas Güttler
Am Fr., 11. Juni 2021 um 03:17 Uhr schrieb Stephan Hoyer : > On Thu, Jun 10, 2021 at 7:10 AM Chris Angelico wrote: > >> This proposal is basically for a way to take an f-string-like >> construct and, instead of calling format() on each of the values and >> joining them together into a string, you

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

2021-06-10 Thread Thomas Güttler
Am Fr., 11. Juni 2021 um 00:10 Uhr schrieb Christopher Barker < python...@gmail.com>: > There may well be use cases for this, but one thing struck me. From the > PEP: > > "Template Literals provide an easy way to access the local and global > variables (like f-strings), so that passing a dictionar

[Python-ideas] Re: Define functions without parentheses (if no parameters given)

2021-06-10 Thread Cameron Simpson
On 10Jun2021 22:57, Johnathan Irvin wrote: >non sequitur Au contraire! Seems relevant to me. >Route functions as seen in flask or fastapi. > >These functions are often decorated by a route, and may not apply here but >are often found with routes that return a page that doesn't take parameters >s

[Python-ideas] Re: Define functions without parentheses (if no parameters given)

2021-06-10 Thread Cameron Simpson
On 11Jun2021 10:01, Cameron Simpson wrote: >So your idea does not suck. But it may not motivate anyone to implement >it, or even to agreed that it should be implemented. It also struck me: functions with _no_ parameters are pretty rare. I had a glance through my own code and aside from some clos

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

2021-06-10 Thread Stephan Hoyer
On Thu, Jun 10, 2021 at 7:10 AM Chris Angelico wrote: > This proposal is basically for a way to take an f-string-like > construct and, instead of calling format() on each of the values and > joining them together into a string, you do something else with it. Or > from a language perspective, you

[Python-ideas] Re: Define functions without parentheses (if no parameters given)

2021-06-10 Thread Cameron Simpson
On 10Jun2021 23:07, Boštjan Mejak wrote: >Thank you, Steve, for your answer. You're absolutely right. But I needed an >answer to clarify that my idea, well, sucks. > >I was just relating to class definitions -- being able to do 'class >MyClass: pass' -- and had an idea about having this same >n

[Python-ideas] Re: Define functions without parentheses (if no parameters given)

2021-06-10 Thread Boštjan Mejak
Thank you, Steve, for your answer. You're absolutely right. But I needed an answer to clarify that my idea, well, sucks. I was just relating to class definitions -- being able to do 'class MyClass: pass' -- and had an idea about having this same non-parenthesized version in case of no given par

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

2021-06-10 Thread Christopher Barker
There may well be use cases for this, but one thing struck me. From the PEP: "Template Literals provide an easy way to access the local and global variables (like f-strings), so that passing a dictionary to the Template is not necessary." This seems to be crossing the line between "data" and "cod

[Python-ideas] Define functions without parentheses (if no parameters given)

2021-06-10 Thread Stephen J. Turnbull
Boštjan Mejak writes: > *** > What if we could define functions (that don't have any parameters) like this: > > def my_function: > pass > > *** > Is that a possible scenario at this point, or even desirable? I'm sure it's possible, but the argument lists are very different in nature

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

2021-06-10 Thread Stephen J. Turnbull
Thomas Güttler writes: > This really helps developers to avoid cross-site-scripting attacks > by enabling a secure escaping of all strings which are not > explicitly marked as safe. Frameworks can already do this by unconditionally applying a function like conditional_escape to all evaluated t

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

2021-06-10 Thread Ricky Teachey
On Thu, Jun 10, 2021 at 10:12 AM Stestagg wrote: > > On Thu, Jun 10, 2021 at 2:58 PM Ricky Teachey wrote: > >> Something I don't understand is whether there is anything about this >> proposed feature that can't be accomplished with a simple function... >> > > > >> >> And use it like this: >

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

2021-06-10 Thread Thomas Güttler
Am Do., 10. Juni 2021 um 16:04 Uhr schrieb Chris Angelico : > On Thu, Jun 10, 2021 at 11:50 PM Thomas Güttler > wrote: > > > What's the advantage of htmx? When I want to build a good interactive > web site, my general pattern is a back end with a well-defined API, > and a front end in JavaScript

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

2021-06-10 Thread Thomas Güttler
Am Do., 10. Juni 2021 um 15:48 Uhr schrieb Felipe Rodrigues < fel...@felipevr.com>: > Well, I share Rob's concern but I do see the point of this: > > > Template Literals only make sense if you want to escape values like in > HTML, XML or SQL templates. > > Maybe they should have a name to better r

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

2021-06-10 Thread Stestagg
On Thu, Jun 10, 2021 at 7:31 AM Thomas Güttler wrote: > Thank you Guido, Chris, Matt and Richard for your feedback to my last > email. > > Here is an updated version called "Template Literals". > > I much prefer: Alternative Ideas Instead of backticks for example t'...' could be used. instead

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

2021-06-10 Thread Stestagg
On Thu, Jun 10, 2021 at 2:58 PM Ricky Teachey wrote: > Something I don't understand is whether there is anything about this > proposed feature that can't be accomplished with a simple function... > > > And use it like this: > > >>> templify("Here, have some {foo}.") > TemplateLiteral(t

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

2021-06-10 Thread Chris Angelico
On Thu, Jun 10, 2021 at 11:58 PM Ricky Teachey wrote: > > Something I don't understand is whether there is anything about this proposed > feature that can't be accomplished with a simple function. > > IIUC, the proposal turns this: > > foo = "spam & eggs" > `Here, have some {foo}.` > > ...into so

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

2021-06-10 Thread Chris Angelico
On Thu, Jun 10, 2021 at 11:50 PM Thomas Güttler wrote: > > > > Am Do., 10. Juni 2021 um 15:33 Uhr schrieb David Mertz : >> >> Strong -1 >> >> As others noted in prior discussion, even if this existed, it works be an >> anti-pattern for SQL. So basically, it's just baking in an HTML-only >> templ

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

2021-06-10 Thread Ricky Teachey
Something I don't understand is whether there is anything about this proposed feature that can't be accomplished with a simple function. IIUC, the proposal turns this: foo = "spam & eggs" `Here, have some {foo}.` ...into something like this (I am making up a more readable repr): TemplateLiteral

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

2021-06-10 Thread Stestagg
On Thu, Jun 10, 2021 at 2:35 PM David Mertz wrote: > Strong -1 > > As others noted in prior discussion, even if this existed, it works be an > anti-pattern for SQL. So basically, it's just baking in an HTML-only > template language into the language syntax. > > The discussion I could find on the

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

2021-06-10 Thread Felipe Rodrigues
Well, I share Rob's concern but I do see the point of this: > Template Literals only make sense if you want to escape values like in HTML, XML or SQL templates. Maybe they should have a name to better reflect this intended use case? Safe Templates, Escaped Strings, I don't know, I'm terrible at n

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

2021-06-10 Thread Thomas Güttler
Am Do., 10. Juni 2021 um 15:33 Uhr schrieb David Mertz : > Strong -1 > > As others noted in prior discussion, even if this existed, it works be an > anti-pattern for SQL. So basically, it's just baking in an HTML-only > template language into the language syntax. > > Python already had excellent H

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

2021-06-10 Thread David Mertz
Strong -1 As others noted in prior discussion, even if this existed, it works be an anti-pattern for SQL. So basically, it's just baking in an HTML-only template language into the language syntax. Python already had excellent HTML templating in libraries. The fact Django has a function with a lon

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

2021-06-10 Thread Thomas Güttler
Am Do., 10. Juni 2021 um 14:42 Uhr schrieb Rob Cliffe via Python-ideas < python-ideas@python.org>: > I am concerned that we have too many string formatting methods: > % formatting > .format() > f-strings > string templates > (are there others I've missed?). > And now we have anothe

[Python-ideas] Define functions without parentheses (if no parameters given)

2021-06-10 Thread Boštjan Mejak
The syntax to define a class looks like this: class MyClass: pass Nice and neat. *** And the syntax to define a function looks like this: def my_function(): pass Hmmm... *** What if we could define functions (that don't have any parameters) like this: def my_function: pass *** I

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

2021-06-10 Thread Rob Cliffe via Python-ideas
I am concerned that we have too many string formatting methods:     % formatting     .format()     f-strings     string templates (are there others I've missed?). And now we have another proposed one. It's all getting a bit much.  And IMO a turnoff for people learning Python (which one should I u