# PEP 845: Leading-Dot Value Patterns

**URL:** <https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100>\
**Category:** PEPs\
**Created:** [September 17, 2026, 7:48pm UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100 "2026-09-17T19:48:08Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tmk](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tmk/32/10935_2.png) [@tmk](https://discuss.python.org/u/tmk)\
**Post date:** [September 17, 2026, 7:48pm UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100/1 "2026-09-17T19:48:08Z")

</div>

For your consideration: [PEP 845](https://peps.python.org/pep-0845/), with the following abstract:

> This PEP enables the use of non-attribute names as **value patterns** in match statements. A name prefixed with a dot is looked up using the normal name resolution rules and compared to the match subject by equality in the same manner as existing value patterns, instead of being treated as a **capture pattern**. This makes it possible to match local variables and global variables defined in the same module without using a guard clause.

```python
def get_book_titles_for_author(author: str):
    for book in BOOKS:
        match book:
            case {"title": title, "author": .author}:
                yield title

```

You can also try it out in the demo here: [https://pep845-demo.pages.dev/](https://pep845-demo.pages.dev/)

> **[PEP 845 – Leading-Dot Value Patterns | peps.python.org](https://peps.python.org/pep-0845/)**
>
> This PEP enables the use of non-attribute names as value patterns in match statements. A name prefixed with a dot is looked up using the normal name resolution rules and compared to the match subject by equality in the same manner as existing value...

---

<div class="post-metadata">

**Author:** ![NeilGirdhar](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/neilgirdhar/32/5776_2.png) [@NeilGirdhar](https://discuss.python.org/u/NeilGirdhar)\
**Post date:** [September 18, 2026, 12:56am UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100/2 "2026-09-18T00:56:44Z")

</div>

Cool idea! Is `Literal[author]` possible? Or does that violate `Literal`’s normal usage too much? Feel free to add it to rejected ideas.

---

<div class="post-metadata">

**Author:** ![cdce8p](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cdce8p/32/3575_2.png) [@cdce8p](https://discuss.python.org/u/cdce8p)\
**Post date:** [September 18, 2026, 1:20am UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100/3 "2026-09-18T01:20:15Z")

</div>

Not exactly sure what you’re referring to. Would you mind posting a small example? That might help me better understand what you’re getting at. Feel free to also try out the online demo linked above.

---

<div class="post-metadata">

**Author:** ![NeilGirdhar](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/neilgirdhar/32/5776_2.png) [@NeilGirdhar](https://discuss.python.org/u/NeilGirdhar)\
**Post date:** [September 18, 2026, 1:21am UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100/4 "2026-09-18T01:21:56Z")

</div>

I just mean instead of `.author` as syntax.

---

<div class="post-metadata">

**Author:** ![cdce8p](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cdce8p/32/3575_2.png) [@cdce8p](https://discuss.python.org/u/cdce8p)\
**Post date:** [September 18, 2026, 1:27am UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100/5 "2026-09-18T01:27:22Z")

</div>

I don’t think that will work. The match statement mini-syntax doesn’t support `[]`. Even `( )` isn’t recognized as a function call but an `isinstance` check instead. So we’d first have to define what `[]` means for pattern matching.

---

<div class="post-metadata">

**Author:** ![Mushrimpy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mushrimpy/32/37444_2.png) [@Mushrimpy](https://discuss.python.org/u/Mushrimpy)\
**Post date:** [September 18, 2026, 2:31am UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100/6 "2026-09-18T02:31:18Z")

</div>

Very cool, I really like the intuitive syntax choice!

I don’t think the following is specified: can `.NAME` resolve to an identifier captured earlier in the same pattern?

```python
match seq:
    case [x, *_, .x]: # first and last elements are equal
        ...    

```

If so, it would also raise the question of precedence in case of a conflict.

c.f. [Elixir’s pin (^) operator](https://elixir.hexdocs.pm/pattern-matching.html#the-pin-operator) is strictly for existing bindings, though it also supports **non-linear** matching via repetition.

---

<div class="post-metadata">

**Author:** ![antonagestam](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/antonagestam/32/12473_2.png) [@antonagestam](https://discuss.python.org/u/antonagestam)\
**Post date:** [September 18, 2026, 6:20am UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100/7 "2026-09-18T06:20:33Z")

</div>

This looks like a good solution to this problem. I have had to work around this issue, in one case introducing a wrapping object just so that I could match it with `box.value`.

+1 from me on this idea.

---

<div class="post-metadata">

**Author:** ![UltimateLobster](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ultimatelobster/32/9727_2.png) [@UltimateLobster](https://discuss.python.org/u/UltimateLobster)\
**Post date:** [September 18, 2026, 8:09am UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100/8 "2026-09-18T08:09:39Z")

</div>

I don’t know how intuitive this syntax is for me. It kinda looks like you try to match an object that has an `author` attribute. (Like some sort of an inline `Protocol`).

---

<div class="post-metadata">

**Author:** ![cdce8p](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cdce8p/32/3575_2.png) [@cdce8p](https://discuss.python.org/u/cdce8p)\
**Post date:** [September 18, 2026, 8:52am UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100/9 "2026-09-18T08:52:55Z")

</div>

> [@Mushrimpy](#):
>
> I don’t think the following is specified: can `.NAME` resolve to an identifier captured earlier in the same pattern?
> 
> ```python
> match seq:
> case [x, *_, .x]: # first and last elements are equal
> ...    
> 
> ```

That’s not possible. Name captures are only assigned after the pattern itself matched (but before the guard is evaluated). Therefore your example would raise an error.

```py
>>> match [1, 1]:
... case [x, *_, .x]:
... pass
...        
Traceback (most recent call last):
  File "<python-input-8>", line 2, in <module>
    case [x, *_, .x]:
                  ^
NameError: name 'x' is not defined

```

---

<div class="post-metadata">

**Author:** ![a-reich](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/a-reich/32/5885_2.png) [@a-reich](https://discuss.python.org/u/a-reich)\
**Post date:** [September 18, 2026, 2:14pm UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100/10 "2026-09-18T14:14:20Z")

</div>

I wish I had something more interesting to contribute other than I’m very much in favor of this, and see little downside!

---

<div class="post-metadata">

**Author:** ![hugovk](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/hugovk/32/14505_2.png) [@hugovk](https://discuss.python.org/u/hugovk)\
**Post date:** [October 9, 2026, 9:25am UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100/11 "2026-10-09T09:25:33Z")

</div>

Let’s close this topic and continue in [PEP 845: Leading-Dot Value Patterns for match statement](https://discuss.python.org/t/pep-845-leading-dot-value-patterns-for-match-statement/109405).

@stoneleaf Please update the Discussions-To and Post-History headers in the PEP to point to the new topic.

Thanks!

---

<div class="post-metadata">

**Author:** ![davidism](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/davidism/32/3295_2.png) [@davidism](https://discuss.python.org/u/davidism)\
**Post date:** [October 9, 2026, 1:44pm UTC](https://discuss.python.org/t/pep-845-leading-dot-value-patterns/109100/12 "2026-10-09T13:44:50Z")

</div>


