# PEP 750: Tag Strings For Writing Domain-Specific Languages

**URL:** <https://discuss.python.org/t/pep-750-tag-strings-for-writing-domain-specific-languages/60408>\
**Category:** PEPs\
**Created:** [August 9, 2024, 3:40pm UTC](https://discuss.python.org/t/pep-750-tag-strings-for-writing-domain-specific-languages/60408 "2024-08-09T15:40:07Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![lys.nikolaou](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/lys.nikolaou/32/2339_2.png) [@lys.nikolaou](https://discuss.python.org/u/lys.nikolaou)\
**Post date:** [August 9, 2024, 3:40pm UTC](https://discuss.python.org/t/pep-750-tag-strings-for-writing-domain-specific-languages/60408/1 "2024-08-09T15:40:07Z")

</div>

Hi! 👋

We are very excited to present [PEP 750 - Tag Strings For Writing Domain-Specific Languages](https://peps.python.org/pep-0750/). We believe that tag strings will be a great addition to Python, which will make string processing and writing Python-based DSLs much easier. We look forward to hearing everyone’s feedback!

## Abstract

This PEP introduces tag strings for custom, repeatable string processing. Tag strings are an extension to f-strings, with a custom function – the “tag” – in place of the `f` prefix. This function can then provide rich features such as safety checks, lazy evaluation, domain-specific languages (DSLs) for web templating, and more.

Tag strings are similar to [JavaScript tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) and related ideas in other languages. The following tag string usage shows how similar it is to an `f` string, albeit with the ability to process the literal string and embedded values:

```python
name = "World"
greeting = greet"hello {name}"
assert greeting == "Hello WORLD!"

```

Tag functions accept prepared arguments and return a string:

```python
def greet(*args):
    """Tag function to return a greeting with an upper-case recipient."""
    salutation, recipient, *_ = args
    getvalue, *_ = recipient
    return f"{salutation.title().strip()} {getvalue().upper()}!"

```

Below you can find richer examples. As a note, an implementation based on CPython 3.14 exists, as discussed in this document.

## PEP

> **[PEP 750 – Template Strings | peps.python.org](https://peps.python.org/pep-0750/)**
>
> This PEP introduces template strings for custom string processing.

---

_[View the full topic](https://discuss.python.org/t/pep-750-tag-strings-for-writing-domain-specific-languages/60408)._
