[issue17959] Alternate approach to aliasing for PEP 435

2013-05-13 Thread Nick Coghlan
Nick Coghlan added the comment: I just wanted to note that there's a trivial way to prevent accidental aliases inline or in your test suite if you don't intend them: class MyEnum(Enum): assert len(MyEnum) == len(MyEnum.__members__) --

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-13 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: On May 12, 2013, at 06:51 AM, Nick Coghlan wrote: class Shape(Enum): >... square = 2 >... diamond = 1 >... circle = 3 >... alias_for_square = square I see Guido pronounced against it, but I'm just registering that I kind of like this. You could p

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-13 Thread Barry A. Warsaw
Changes by Barry A. Warsaw : -- nosy: +barry ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-12 Thread Nick Coghlan
Nick Coghlan added the comment: OK, I mainly wanted to make sure this alternative was at least considered, as I didn't see it come up during the PEP discussions. -- dependencies: -Code, test, and doc review for PEP-0435 Enum resolution: -> rejected stage: needs patch -> committed/reje

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-12 Thread Guido van Rossum
Guido van Rossum added the comment: I'm with Antoine. Trying to prevent accidental redefinition behavior like Nick proposes feels like un-Pythonic coddling to me, and I expect we'd be closing off some occasionally useful patterns. Please leave well enough alone. -- _

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-12 Thread Nick Coghlan
Nick Coghlan added the comment: The difference is the use case: dicts are a general purpose data store, enums are typically for defining mutually exclusive named values, with aliasing as a concession to practical reality. -- ___ Python tracker

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: Also, since we currently don't forbid the following: >>> {'a': 1, 'a': 2} {'a': 2} I don't see why enums should be any different. Recommend closing. -- ___ Python tracker ___

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: That's way too much magic for my taste. -- nosy: +pitrou ___ Python tracker ___ ___ Python-bugs-list

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-12 Thread Stefan Drees
Changes by Stefan Drees : -- nosy: +dilettant ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pytho

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-12 Thread Guido van Rossum
Changes by Guido van Rossum : -- nosy: +gvanrossum ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-12 Thread Nick Coghlan
Nick Coghlan added the comment: Hmm, that's an interesting point about allowing operations on the already defined values. You could get around that by requiring that the wrapper be explicit when definined the alias: >>> class Shape(enum.Enum): ... rectangle = 1 ... oblong = enum.alias(rec

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-12 Thread Ethan Furman
Ethan Furman added the comment: Another approach to handling this, and other, issues is to allow options to EnumMeta. My original aenum code had the default Enum class as unordered, no duplicates allowed, non-indexable, etc., but then allowed options to be passed in such as DUPLICATES to allo

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-12 Thread Eric V. Smith
Changes by Eric V. Smith : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyt

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-12 Thread Nick Coghlan
Changes by Nick Coghlan : -- priority: normal -> high ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://ma

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-12 Thread Nick Coghlan
Nick Coghlan added the comment: That's a terrible way to express aliasing, because it's really unclear that "rectangle" is the canonical name. By contrast: class Shape(Enum): rectangle = 2 oblong = rectangle leaves no doubt as to which is canonical and which is the alias. You never

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-11 Thread Alex Gaynor
Alex Gaynor added the comment: This would preclude code like: class Shape(Enum): rectangle = shape = 2 which seems (to me) to be the most reasonable way to express aliasing. -- nosy: +alex ___ Python tracker __

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-11 Thread Nick Coghlan
Changes by Nick Coghlan : -- dependencies: +Code, test, and doc review for PEP-0435 Enum ___ Python tracker ___ ___ Python-bugs-list m

[issue17959] Alternate approach to aliasing for PEP 435

2013-05-11 Thread Nick Coghlan
New submission from Nick Coghlan: Creating this as a separate issue so as not to delay incorporation of the accepted PEP. One legitimate criticism of the accepted PEP 435 is that the combination of requiring explicit assignment of values *and* allowing aliasing by default is that aliases may