PEP 354: Enumerations in Python

Tim Chase python.list at tim.thechases.com
Wed Mar 1 07:19:18 CET 2006


>> Do you anticipate having parameters like socket.AF_INET
>> that are currently integers, become enumeration members
>> in future releases?
> 
> Since these are derived from values defined as integers
> in C, it's probably better to leave them that way. There
> may be code that relies on them being integers or having
> those integer values.

I'd say that "because something is done in C, it's the best 
way to do it in Python" is a bad line of reasoning :)  If I 
wanted C, I'd use C.  ("some C API functions take pointers 
to arbitrary blocks of memory...python should [natively] 
implement pointers to arbitrary blocks of memory..." kinda 
scares me to be frank...that's why there's the ability to 
write clean wrappers in C or C++ to expose such things)

The backwards-compatibility-with-existing-code is a much 
better reason :)

-tkc








More information about the Python-list mailing list