# Allow for arbitrary string prefix of strings

**URL:** <https://discuss.python.org/t/allow-for-arbitrary-string-prefix-of-strings/19740>\
**Category:** Ideas\
**Created:** [October 6, 2022, 12:38pm UTC](https://discuss.python.org/t/allow-for-arbitrary-string-prefix-of-strings/19740 "2022-10-06T12:38:45Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![jimbaker](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jimbaker/32/21490_2.png) [@jimbaker](https://discuss.python.org/u/jimbaker)\
**Post date:** [October 7, 2022, 9:19pm UTC](https://discuss.python.org/t/allow-for-arbitrary-string-prefix-of-strings/19740/12 "2022-10-07T21:19:15Z")

</div>

> [@PMLP-novo](#):
>
> Regarding opening Python more up to SQL injections. I acturaly think it would make people more aware of SQL injections. Because having such tags would allow the IDE to give warnings to the users much better, because they can use the tags to understand what is happening better.

To be very clear, a properly written `sql` tag, or for that matter a tag for some other DSL, should not suffer from injection attacks in its usage. This is because the tag function can clearly delineate between text from the template, which can be trusted; and the interpolations, which have to be quoted, bound, or otherwise worked with.

> [@](#):
>
> Regarding if IDE’s are interested in it. Wouldn’t you think that somebody would make a VScode extension that looked for patterns like (sql") and applied an sql syntax highlighter to the string if it was posible?

It seems possible for a plugin for an IDE to support this for some arbitrary tag and its associated DSL. IDEs track explicit definitions/imports to determine the source of a name; and in principle, they presumably could call a registered plugin on specific usage in a tagstring. It would be very cool if they could do this, especially because language support is already available for so many DSLs that could be used - HTML, SQL, shell, etc - they would just need to take into account any interpolations that are used; and work around that.

> [@](#):
>
> Regarding core tags vs user defined tags. My original thourgh was that user defined tags ended with “\_” which would also allow for tag chaining, but it is probably a bad idea, and I’m not sure it is a problem. I could imagine an IDE highlighting if there is a name colision between core tag vs user defined tag.

It’s a good question. Here’s one possible answer with respect to name collisions. I will often use `f` as generic function name, or for a throwaway function when using the REPL. But I have never confused that usage with using a f-string. That’s one anecdote, but my feeling here is that the syntactic position really matters.

In any event, if name collisions are a problem, that’s something an IDE could certainly determine for a user.

---

_[View the full topic](https://discuss.python.org/t/allow-for-arbitrary-string-prefix-of-strings/19740)._
