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
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
Am Do., 10. Juni 2021 um 14:42 Uhr schrieb Rob Cliffe via Python-ideas <
[email protected]>:
> 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
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
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
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
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
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
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
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
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
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
Am Do., 10. Juni 2021 um 15:48 Uhr schrieb Felipe Rodrigues <
[email protected]>:
> 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
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
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:
>
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
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
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
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
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
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
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
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
Am Fr., 11. Juni 2021 um 00:10 Uhr schrieb Christopher Barker <
[email protected]>:
> 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
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
25 matches
Mail list logo