[Python-Dev] PEP 435: pickling enums created with the functional API
Nick Coghlan
ncoghlan at gmail.com
Tue May 7 17:06:29 CEST 2013
On Wed, May 8, 2013 at 12:53 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 05/07/2013 07:48 AM, Piotr Duda wrote:
>>
>>
>> What about adding simple syntax (I proposed this earlier, but no one
>> commented) that take care of assigning name and module, something
>> like:
>>
>> def name = expression
>>
>> which would be rough equivalent for:
>>
>> name = expression
>> name.__name__ = 'name'
>> name.__module__ = __name__
>
>
> How is that different from
>
> --> name = Enum('module.name', ... )
With the repetition, you're setting yourself up for bugs in future
maintenance when either the module name or the assigned name change.
I like Piotr's suggestion of simply assigning to __name__ and
__module__ after the fact, though - much simpler than my naming
context idea.
Cheers,
Nick.
More information about the Python-Dev
mailing list