[Python-ideas] Enums

Robert Kern robert.kern at gmail.com
Mon Jul 25 22:33:55 CEST 2011


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




More information about the Python-ideas mailing list