[issue34750] locals().update doesn't work in Enum body, even though direct assignment to locals() does

Antony Lee report at bugs.python.org
Sat Sep 22 04:39:30 EDT 2018


Antony Lee <anntzer.lee at gmail.com> added the comment:

> I agree though that adding an update method would be nice though and can be done in just a few lines of code.

Again, this can be done just be inheriting the methods from MutableMapping.

In fact even now one can just write

    class E(Enum): MutableMapping.update(locals(), {"a": 1})

and this will do the "right" thing but that's hardly an obvious way to do it...

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34750>
_______________________________________


More information about the Python-bugs-list mailing list