[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-23 Thread Guido van Rossum
On Thu, Oct 22, 2020 at 11:08 PM Random832 wrote: > (with the PEG parser, incidentally, I wonder if it may be time to revisit > certain limitations in f-string syntax, though that particular one > technically presents a backward compatibility problem that the rest don't) > That's been worked on

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-23 Thread Marco Sulla
On Fri, 23 Oct 2020 at 08:06, Random832 wrote: > On Thu, Oct 22, 2020, at 21:00, Steven D'Aprano wrote: > I suspect that calling this particular syntax ugly is picking at a bit of > an open wound in the history f-string implementation... consider precisely > why the escaping syntax is {{}} instea

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-22 Thread Random832
On Thu, Oct 22, 2020, at 21:00, Steven D'Aprano wrote: > "Who"? Syntax is a person now? > > For what it's worth, I don't think escaping special symbols is ugly. > More like homely. It does the job, plainly and simply, but I don't think > it's especially good looking. Every other character stands

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-22 Thread Steven D'Aprano
On Thu, Oct 22, 2020 at 09:09:07AM -0700, Guido van Rossum wrote: > On Thu, Oct 22, 2020 at 3:37 AM Hans Ginzel wrote: > > > Thank you for (ugly) workaorund. > > > > Careful who you're calling ugly. "Who"? Syntax is a person now? For what it's worth, I don't think escaping special symbols is u

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-22 Thread Steven D'Aprano
On Thu, Oct 22, 2020 at 12:29:22PM +0200, Hans Ginzel wrote: > >We could do that, but this is more likely to just hide bugs in the > >f-string than be useful. > > Thank you, that would be great and useful. Oh, sorry Hans, I think that you may have misunderstood me. In English, "We could do that

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-22 Thread Guido van Rossum
On Thu, Oct 22, 2020 at 3:37 AM Hans Ginzel wrote: > Thank you for (ugly) workaorund. > Careful who you're calling ugly. -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)*

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-22 Thread Hans Ginzel
On Thu, Oct 22, 2020 at 11:32:36PM +1100, Chris Angelico wrote: My recommendation here would be to separate the part where you insert a table name from the rest of the statement: cursor.execute(f"INSERT INTO {table} " "VALUES (1, '{}')") That way, you aren't at risk of SQL injection in the res

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-22 Thread Chris Angelico
On Thu, Oct 22, 2020 at 8:12 PM Hans Ginzel wrote: > > Hello, > > consider this snippet please > > cursor.execute(f"INSERT INTO {table} VALUES (1, '{}');") > SyntaxError: f-string: empty expression not allowed > > It is (absolutely) correct to insert empty json into database table field. > Empty e

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-22 Thread Marco Sulla
On Thu, 22 Oct 2020 at 12:36, Hans Ginzel wrote: > On Thu, Oct 22, 2020 at 08:31:34PM +1100, Steven D'Aprano wrote: > >> cursor.execute(f"INSERT INTO {table} VALUES (1, '{}');") > >> SyntaxError: f-string: empty expression not allowed > > > >Escape the braces by doubling them: > >f"INSERT INT

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-22 Thread Eric V. Smith
On 10/22/2020 4:58 AM, Hans Ginzel wrote: Hello, consider this snippet please cursor.execute(f"INSERT INTO {table} VALUES (1, '{}');") SyntaxError: f-string: empty expression not allowed It is (absolutely) correct to insert empty json into database table field. Empty expression in f-string s

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-22 Thread André Roberge
On Thu, Oct 22, 2020 at 7:39 AM Hans Ginzel wrote: > On Thu, Oct 22, 2020 at 08:31:34PM +1100, Steven D'Aprano wrote: > >> cursor.execute(f"INSERT INTO {table} VALUES (1, '{}');") > >> SyntaxError: f-string: empty expression not allowed > > > >Escape the braces by doubling them: > >f"INSERT I

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-22 Thread Paul Moore
On Thu, 22 Oct 2020 at 11:39, Hans Ginzel wrote: > > On Thu, Oct 22, 2020 at 08:31:34PM +1100, Steven D'Aprano wrote: > >> cursor.execute(f"INSERT INTO {table} VALUES (1, '{}');") > >> SyntaxError: f-string: empty expression not allowed > > > >Escape the braces by doubling them: > >f"INSERT IN

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-22 Thread Hans Ginzel
On Thu, Oct 22, 2020 at 08:31:34PM +1100, Steven D'Aprano wrote: cursor.execute(f"INSERT INTO {table} VALUES (1, '{}');") SyntaxError: f-string: empty expression not allowed Escape the braces by doubling them: f"INSERT INTO {table} VALUES (1, '{{}}');" Thank you for (ugly) workaorund. Th

[Python-ideas] Re: f-string: empty expression should be allowed

2020-10-22 Thread Steven D'Aprano
On Thu, Oct 22, 2020 at 10:58:00AM +0200, Hans Ginzel wrote: > Hello, > > consider this snippet please > > cursor.execute(f"INSERT INTO {table} VALUES (1, '{}');") > SyntaxError: f-string: empty expression not allowed Escape the braces by doubling them: f"INSERT INTO {table} VALUES (1, '{{