- edited description
Regression: Enum.enums returning list instead of tuple
The Enum.enums returning a list now instead of tuple.
Was this by design (I couldn't find it in the documentation)?
Imo it makes more sense to keep it immutable as tuple.
Comments (7)
-
reporter -
repo owner your code is actually dependent on that?
-
repo owner it's dynamically generated now. Also I prefer using lists for variable-length sequences of homogeneous items. tuples are for fixed-length lists of heterogeneous items. I've been in a lot of religious wars over this one but Ned sums it up here: http://nedbatchelder.com/blog/201608/lists_vs_tuples.html
The Cultural Difference is about how lists and tuples are actually used: lists are used where you have a homogenous sequence of unknown length; tuples are used where you know the number of elements in advance because the position of the element is semantically significant.
In an enum, the position of the element is not semantically significant.
-
reporter Sort of, yes. We have functions that assume input to be tuples.
We are then passing the Enum.enums. So that failed after I upgraded to 1.1.2. I can just cast it, so this is not a big issue. Just thought it might be worth mentioning :)
-
reporter My argumentation was: The list should never change after it's defined, so it should probably be a tuple. But your comment also makes sense. Personally I don't really care, just thought I'd mention it.
Guess this can be closed then.
-
repo owner - changed status to resolved
Document Enum.enums is now a list
Change-Id: I27251c262f919df1b084cbb08759f672f05cd3f7 Fixes:
#3834→ <<cset 39d5a9726654>>
-
repo owner it's true the "lists are mutable" thing is what really prevents this list/tuple issue from being a simple thing in Python. There might be an immutablelist floating around in the codebase, i know i have one for dict.
- Log in to comment