[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library (original) (raw)
Barry Warsaw barry at python.org
Sat Apr 13 00:23:30 CEST 2013
- Previous message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Next message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Apr 12, 2013, at 12:56 PM, Guido van Rossum wrote:
Agreed. I can't easily find that in the PEP though. It doesn't mention getitem and I can't find any examples of using [].
Indeed, this looks like an omission in the PEP. flufl.enum's usage documentation definitely talks about this:
http://pythonhosted.org/flufl.enum/docs/using.html
specifically:
http://pythonhosted.org/flufl.enum/docs/using.html#conversions
Eli, care to add this to the PEP?
Should the metaclass-based API used to create IntEnum be documented, so strongly motivated people can write their own crazy variants?
I think you recommended against that in python-ideas :). I have changed my mind; I am now at least +0 on documenting the metaclass craziness.
It would be fine with me. I left it out of the flufl.enum docs and we left it out of the PEP after your original comments, but I'm pretty happy with the API and can't foresee us changing it (famous last words).
FWIW, we use a special attribute called value_factory on the Enum subclass to name the class used to create enum values. This is all there is to IntEnum:
class IntEnum(Enum): """A specialized enumeration with values that are also integers.""" value_factory = IntEnumValue
and even the IntEnumValue class isn't that big. It can be even smaller in Python 3.4 because of the workarounds in flufl.enum for Python 2 compatibility, and deprecations.
Eli, what do you think about documenting the extension API?
Cheers, -Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-dev/attachments/20130412/04179c5d/attachment.pgp>
- Previous message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Next message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]