I have an Enum class Station. (I'm using aenum, a library that "extends" python enum, and allows to use enums that have both an integer and a string) This class Station) stores constants, with number and string representation. All fine.
Now, I want to store constant lists of Station objects. What I'm doing works but feels wrong. (I'm kind of new to python / programing.) Does someone have an advice on that ? thank you.
Here is my code :
from typing import List from aenum import Enum from abc import ABC class Station(Enum): _init_ = 'value string' BASTILLE = 3, 'Bastille' LEDRU = 1, 'Ledru Rollin' REPU = 10, 'République' CHATELET = 2, 'Châtelet les Halles' OURCQ = 5, 'Ourcq' def __str__(self): return self.string @property def nb(self): return self.value class StationEnsemble(ABC): name :str stations : List[Station] @property def station_nbs_list(self): return [st.nb for st in self.stations] class RecentStations(StationEnsemble): stations = [Station.OURCQ,Station.LEDRU,Station.CHATELET] class EastStations(StationEnsemble): stations=[Station.BASTILLE,Station.OURCQ,Station.CHATELET]
RECENT_STATIONS = [Station.OURCQ, Station.LEDRU, Station.CHATELET]etc.?