[Python-Dev] PEP-435 reference implementation (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Fri May 3 03:10:04 CEST 2013


On Thu, May 2, 2013 at 11:37 AM, Steven D'Aprano <steve at pearwood.info> wrote:

On 02/05/13 08:54, Nick Coghlan wrote:

If enums had an "asdict" method that returned an ordered dictionary, you could do:

class MoreColors(Enum): locals().update(Colors.asdict()) Surely that is an implementation-specific piece of code? Writing to locals() is not guaranteed to work, and the documentation warns against it. http://docs.python.org/3/library/functions.html#locals

I've long thought we should stop being wishy-washy about modification of locals(), and make the current CPython behaviour part of the language spec:

I'll start a separate thread about that.

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list