[Python-ideas] Enums

Michael Foord fuzzyman at gmail.com
Mon Jul 25 23:40:11 CEST 2011


On 25 July 2011 21:33, Robert Kern <robert.kern at gmail.com> wrote:

> On 7/25/11 2:09 PM, Michael Foord wrote:
>
>>
>>
>> On 25 July 2011 19:47, Raymond Hettinger
>> <raymond.hettinger at gmail.com
>> <mailto:raymond.hettinger@**gmail.com <raymond.hettinger at gmail.com>>>
>> wrote:
>>
>>
>>    On Jul 25, 2011, at 1:06 PM, Michael Foord wrote:
>>
>>>
>>>    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)
>>>
>>
>>    What is being proposed here?  Will there be a new namespace so that we
>> would
>>    start writing re.Flags.IGNORECASE instead of re.IGNORECASE?  Are module
>>    level constants now going to be considered bad-form?
>>
>>    If constants switch from re.IGNORECASE to re.flags.IGNORECASE, are
>> there any
>>    benefits to compensate for being both wordier and slower?
>>
>>
>> Nope. Just something like this at the module level.
>>
>> IGNORECASE = Flags.IGNORECASE
>>
>> What it gains you is a nicer representation when looking at the values
>> when
>> debugging.
>>
>
> +1. It's not a problem I run into every time I debug something, but it
> happens often enough that the feeling of frustration is quite familiar each
> time it crops up. It's like an old college acquaintance that shows up to
> crash "just a few nights" on your couch every time he's in town.
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma
>  that is made terrible by our own mad attempt to interpret it as though it
> had
>  an underlying truth."
>  -- Umberto Eco
>
>
> ______________________________**_________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas>
>



-- 

http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110725/8aa3e42f/attachment.html>


More information about the Python-ideas mailing list