A RetroSearch Logo

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

Search Query:

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

[Python-Dev] constant/enum type in stdlib

[Python-Dev] constant/enum type in stdlibGreg Ewing greg.ewing at canterbury.ac.nz
Wed Nov 24 00:32:56 CET 2010
Bill Janssen wrote:

> The main purpose of that is to be able to catch type mismatches with
> static typing, though.  Seems kind of pointless for Python.

But catching type mismatches with dynamic typing doesn't
seem pointless for Python. There's nothing static about
the proposals being made here that I can see.

> Why not
> 
>   class Color:
>      red = (255, 0, 0)
>      green = (0, 255, 0)
>      blue = (0, 0, 255)

If all you want is a bunch of named constants, that's fine.
But the facilities being discussed here are designed to give
you other things as well, such as

   c = Color.red
   print(c)

printing "red" rather than "(255, 0, 0)".

-- 
Greg
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