I am looking to facilitate the following behavior, which is NOT just to get a string representation of the class! The following is a SIMPLIFIED version of my problem:
>>> Alphabet.a
'a'
>>> Alphabet.b
'b'
>>> Alphabet.alpha
'α'
>>> Alphabet.a.is_vowel
True
I currently have the following setup. The main reason I chose this over any other approach is that the data I am accessing has to, at most, be set on start-up and that this approach is able to make use of my IDEs code completion feature.
class Character:
def __init__(self, c: str, v: bool):
self.name = c
self.is_vowel = v
class Alphabet:
a: Character = Character('a', True)
b: Character = Character('b', False)
c: Character = Character('c', False)
That already allows me to call Alphabet.a.name
to get the name, however I'd like to be able to only call Alphabet.a
to get the name parameter, while still being able to access Alphabet.a.is_vowel
.