4 ms·
Not really sure what a t string is or if it’s a macro, but feel similar to https://github.com/elixir-dbvisor/sql https://github.com/elixir-dbvisor/sql but less
by schultzer 1y ago
Not really sure what a t string is or if it’s a macro, but feel similar to https://github.com/elixir-dbvisor/sql https://github.com/elixir-dbvisor/sql but less elegant and ergonomic.
- 1_08iu 1y agot-strings (or template strings) are an upcoming Python 3.14 feature. They have similar syntax to f-strings (which were introduced in 3.6) except that they provide access to the string and the interpolated values (the bits inside the curly brackets) before they have been combined. Previously, something like db.query(f"SELECT * FROM table WHERE id={id};") would have been vulnerable to the classic "bobby tables" SQL injection but t-strings allow for almost the same syntax (which is quite natural for Python programmers) without incurring a security risk. If you are curious, t-strings have previously been discussed here (https://news.ycombinator.com/item?id=43748512 https://news.ycombinator.com/item?id=43748512 and https://news.ycombinator.com/item?id=43647716 https://news.ycombinator.com/item?id=43647716) and you can read the PEP that proposed their addition to the language (https://peps.python.org/pep-0750/ https://peps.python.org/pep-0750/).
- deleted 1y ago[deleted]