From the thread last year:
Python standard library modules
currently using integers for constants:
* re - has flags (OR'able constants) defined in sre_constants, each flag
has two names (e.g. re.IGNORECASE and re.I)
* os has SEEK_SET, SEEK_CUR, SEEK_END -
*plus* those implemented in
posix / nt
* doctest has its own flag system, but is really just using integer
flags / constants (quite a few of them)
* token has a tonne of constants (autogenerated)
* socket exports a bunch of constants defined in _socket
* gzip has flags: FTEXT, FHCRC, FEXTRA, FNAME, FCOMMENT
* errno (builtin module)
EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL,
ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED
* opcode has HAVE_ARGUMENT, EXTENDED_ARG. In fact pretty much the whole
of opcode is about defining and exposing named constants
* msilib uses flag constants
* multiprocessing.pool - RUN, CLOSE, TERMINATE
* multiprocessing.util - NOTSET, SUBDEBUG, DEBUG, INFO, SUBWARNING
* xml.dom and xml.dom.Node (in __init__.py) have a bunch of constants
* xml.dom.NodeFilter.NodeFilter holds a bunch of constants (some of them
flags)
* xmlrpc.client has a bunch of error constants
* calendar uses constants to represent weekdays, plus one for the EPOCH
that is best left alone
* http.client has a tonne of constants - recognisable as ports / error
codes though
* dis has flags in COMPILER_FLAG_NAMES, which are then set as locals in
inspect
* io defines SEEK_SET, SEEK_CUR, SEEK_END (same as os)
Where constants are implemented in C but exported via a Python module
(the constants exported by os and socket for example) they could be
wrapped. Where they are exported directly by a C extension or builtin
module (e.g. errno) they are probably best left.
Here's an email from Guido from that thread putting his vote in for enums *as* integers:
http://mail.python.org/pipermail/python-dev/2010-November/105916.html
All the best,
Michael Foord