A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2010-November/105904.html below:

[Python-Dev] constant/enum type in stdlib

[Python-Dev] constant/enum type in stdlibAntoine Pitrou solipsis at pitrou.net
Tue Nov 23 19:06:42 CET 2010
Le mardi 23 novembre 2010 à 12:57 -0500, Fred Drake a écrit :
> On Tue, Nov 23, 2010 at 12:37 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> > Enumerations aren't a type at all (they have no distinguishing
> > property).
> 
> In any given language, this may be true, or not.  Whether they should
> be distinct in Python is core to the current discussion.

I meant "type" in the structural sense (hence the parenthesis). enums
are just auto-generated constants. Since Python makes it trivial to
generate sequential integers, there's no need for a specific "enum"
construct.

Now you may argue that enums should be strongly-typed, but that would be
a bit backwards given Python's preference for duck-typing.

> From a backward-compatibility perspective, what makes sense depends on
> whether they're used to implement existing constants (socket.AF_INET,
> etc.) or if they reserved for new features only.

It's not only backwards compatibility. New features relying on C APIs
have to be able to map constants to the integers used in the C library.
It would be much better if this were done naturally rather than through
explicit conversion maps.
(this really means subclassing int, if we don't want to complicate
C-level code)

Regards

Antoine.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4