Message325864
A quick check suggests that enum entries can be programmatically created by assigning to locals() in the Enum body:
class E(Enum): locals()["a"] = 1
E.a # -> <E.a: 'a'>
However, using locals().update(...) doesn't, and silently does the wrong thing:
class E(Enum): locals().update({"a": "a"})
E.a # -> 'a'
(Yes, in this simple case, I could just use the functional API (`E = Enum("E", [("a", "a")])`), but the above is simpler if I also want e.g. to define methods for the Enum. |
|
Date |
User |
Action |
Args |
2018-09-20 12:39:23 | Antony.Lee | set | recipients:
+ Antony.Lee |
2018-09-20 12:39:23 | Antony.Lee | set | messageid: <1537447163.92.0.956365154283.issue34750@psf.upfronthosting.co.za> |
2018-09-20 12:39:23 | Antony.Lee | link | issue34750 messages |
2018-09-20 12:39:23 | Antony.Lee | create | |
|