Comment by ilyagr

Comment by ilyagr 2 days ago

0 replies

Ah, apparently with real t-strings, `t"SELECT {a-1}"` should be allowed while `t"SELECT {}"` is not.

Here is Python master branch:

    Python 3.15.0a0 (heads/main:ea2d707bd5, May 16 2025, 12:20:56) [Clang 16.0.0 (clang-1600.0.26.6)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> t"Hello {a}"
    Traceback (most recent call last):
      File "<python-input-1>", line 1, in <module>
        t"Hello {a}"
                 ^
    NameError: name 'a' is not defined
    >>> a=3
    >>> t"Hello {a+5}"
    Template(strings=('Hello ', ''), interpolations=(Interpolation(8, 'a+5', None, ''),))
    >>> t"Hello {}"
      File "<python-input-6>", line 1
        t"Hello {}"
                 ^
    SyntaxError: t-string: valid expression required before '}'