+ 1

Enumerations in Python

Is there a module to implement enumerations in python?

27th Nov 2017, 6:16 AM
Marcus Germano
3 Respostas
+ 6
https://docs.python.org/3/library/enum.html from enum import Enum class States(Enum): WA = "Washington" OR = "Oregon" CA = "California" UT = "Utah" NY = "New York" print(States.WA.value)
27th Nov 2017, 6:35 AM
ChaoticDawg
ChaoticDawg - avatar
+ 4
It's a built-in function, no library needed. https://docs.python.org/2/library/functions.html#enumerate
27th Nov 2017, 6:35 AM
Sapphire
+ 3
I guess it depends on which one you're asking about. Enumerate and enumerations are not the same thing, but you have an answer for either, so.... you should be good either way!
27th Nov 2017, 6:41 AM
ChaoticDawg
ChaoticDawg - avatar