For example:
>>> Spoken = namedtuple("Spoken", ["loudness", "pitch"])
>>> s = Spoken(loudness=90, pitch='high')
>>> str(s)
"Spoken(loudness=90, pitch='high')"
What I want is:
>>> str(s)
90
That is I want the string representation to display the loudness attribute.
Is this possible ?
Yes, it is not hard to do and there is an example for it in the namedtuple docs.
The technique is to make a subclass that adds its own str method:
Update:
You can also used typing.NamedTuple to get the same effect.