On Oct 20, 2019, at 03:36, Steve Jorgensen <ste...@stevej.name> wrote: > > Andrew Barnert wrote: >> What you’re describing is just enum.Enum, minus half its features, but a >> sequence >> instead of a mapping. >> I’m not sure why you’d ever want this, > > Actually, it's a bit different. This is for building a collection of > value/label pairs where the values are as likely to be strings as numbers, > and its sequence behavior is as a list of value/label pairs (e.g. for use > as the choices for a Django field).
But the values of an Enum can be strings. And there are multiple PyPI projects that build Django choices on top of Enum, which show that the only thing you need is to override __getitem__ to replace its mapping behavior with sequence behavior. I believe this was also one of the examples of what you can build for yourself on top of EnumMeta in Nick Coghlan’s blog post explaining the design of enum. Maybe the additional functionality in Enum gets in your way for some reason I don’t understand, that doesn’t affect other people who want Django choices. But otherwise, I don’t see how it really is any different. And again, none of this different-from-Enum behavior is relevant to your problem anyway. The fact that you think it is, and think it can’t be done with Enum, makes it harder to understand where the actual problem is. Maybe you’re not just trying to do the same magic that all the autoenum/simplenum/etc. packages on PyPI and the PoC code from the PEP and the section in Nick’s blog post all do (in a couple different ways), or maybe it’s insufficiently magic for your purposes, but without knowing how and why it’s different or insufficient it’s impossible to know whether there’s an actual limitation to fix in Python, or just a problem in your design or implementation that could be easily fixed to work in existing Python. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/CNIE44LOSXLZBCTGROBUNN23DB46CWLZ/ Code of Conduct: http://python.org/psf/codeofconduct/