[Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as (original) (raw)
Barry Warsaw barry at python.org
Mon Feb 25 02:40:00 CET 2013
- Previous message: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as
- Next message: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Feb 23, 2013, at 04:02 PM, Stefan Krah wrote:
+Ordered comparisons between enumeration values are not supported. Enums are +not integers! Hmm. I think this limits interoperation with C libraries and prototyping C code.
This is mostly a red-herring. flufl.enum values are C-level int compatible without actually being ints.
E.g.
static PyObject * intcompat_printint(PyObject *self, PyObject *args) { int value; if (!PyArg_ParseTuple(args, "i", &value)) return NULL;
printf("and the value is: %d\n", value);
Py_RETURN_NONE;
}
from intcompat import * printint(7) and the value is: 7 from flufl.enum import make Colors = make('Colors', 'red green blue'.split()) printint(Colors.green) and the value is: 2
Full module code is here:
http://bazaar.launchpad.net/~barry/+junk/intcompat/files
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/20130224/6710f447/attachment.pgp>
- Previous message: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as
- Next message: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]