# python: Add dunder variables highlighting \(\#58158\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/b914ba5cb3f4619450ad0de38adbb6b215752b74)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: b914ba5cb3f4619450ad0de38adbb6b215752b74

Requested commit: b914ba5cb3f4619450ad0de38adbb6b215752b74

Commit: b914ba5cb3f4619450ad0de38adbb6b215752b74

Tree: 72415d50c47b41dc00609dea0ab49e92abf1dba9

Author: Alex Lachance

Committer: GitHub

## Message

```
python: Add dunder variables highlighting (#58158)

In the current Python Tree-sitter `highlights.scm`, dunder variables
(e.g., `__name__`, `__file__`) are not highlighted.

This PR adds a regex `#match?` so all dunder variables are highlighted
under `@attribute.special`.

An alternative solution would be to use `#any-of?` and list all dunder
variables.


| Before | After |
|
:---------------------------------------------------------------------------------------------------------------------------------:
|
:--------------------------------------------------------------------------------------------------------------------------------:
|
|<img width="623" height="895" alt="image"
src="https://github.com/user-attachments/assets/ad7b67ba-541c-40ac-a38a-cc863e417fcc"
/> | <img width="612" height="903" alt="image"
src="https://github.com/user-attachments/assets/a91f5efb-230a-4214-b16b-04278b3ef9ee"
/>|


Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Added Python dunder variables highlighting via `attribute.special` in
themes.
```

## Parents

- [51db7df7501e672fdfc9fa4875f43215329fc0d9](https://git.cafe/gitcafe/zed/commit/51db7df7501e672fdfc9fa4875f43215329fc0d9?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/b914ba5cb3f4619450ad0de38adbb6b215752b74?format=markdown)
