diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2020-12-10 21:07:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-10 21:07:00 (GMT) |
commit | a65828717982e6a56382d7aff738478f5b5b25d0 (patch) | |
tree | c8148582ad4dc68cd969531dc64a1bee8274756b /Python/pyarena.c | |
parent | efb13be72cbf49edf591936fafb120fe1b7d59f7 (diff) | |
download | cpython-a65828717982e6a56382d7aff738478f5b5b25d0.zip cpython-a65828717982e6a56382d7aff738478f5b5b25d0.tar.gz cpython-a65828717982e6a56382d7aff738478f5b5b25d0.tar.bz2 |
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 'Python/pyarena.c')
0 files changed, 0 insertions, 0 deletions