This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Antony.Lee
Recipients Antony.Lee
Date 2018-09-20.12:39:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1537447163.92.0.956365154283.issue34750@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-09-20 12:39:23Antony.Leesetrecipients: + Antony.Lee
2018-09-20 12:39:23Antony.Leesetmessageid: <1537447163.92.0.956365154283.issue34750@psf.upfronthosting.co.za>
2018-09-20 12:39:23Antony.Leelinkissue34750 messages
2018-09-20 12:39:23Antony.Leecreate