diff options
| author | Ethan Furman <ethan@stoneleaf.us> | 2020-12-10 13:07:00 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-10 13:07:00 -0800 |
| commit | a65828717982e6a56382d7aff738478f5b5b25d0 (patch) | |
| tree | c8148582ad4dc68cd969531dc64a1bee8274756b /Lib/typing.py | |
| parent | efb13be72cbf49edf591936fafb120fe1b7d59f7 (diff) | |
| download | cpython-git-a65828717982e6a56382d7aff738478f5b5b25d0.tar.gz | |
bpo-34750: [Enum] add `_EnumDict.update()` support (GH-23725)
This allows easier Enum construction in unusual cases, such as including dynamic member definitions into a class definition:
# created dynamically
foo_defines = {'FOO_CAT': 'aloof', 'BAR_DOG': 'friendly', 'FOO_HORSE': 'big'}
class Foo(Enum):
vars().update({
k: v
for k, v in foo_defines.items()
if k.startswith('FOO_')
})
def upper(self):
# example method
return self.value.upper()
Diffstat (limited to 'Lib/typing.py')
0 files changed, 0 insertions, 0 deletions
