This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DictTuple(tuple): | |
"""Tuple class with added item getting by name. | |
""" | |
def __new__(cls, d): | |
rv = super().__new__(cls, d.values()) | |
rv._map = d | |
return rv | |
def __repr__(self): | |
return f"{type(self).__qualname__}({self._map!r})" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Convert a codebase to using the walrus operator. | |
Hint: in order to explore the AST of a module you can run: | |
python -m ast path/to/module.py | |
""" | |
from __future__ import annotations |
OlderNewer