When working with namedtuples, it seems there is a default "value" for the object allowing one to compare two named tuples with the < >
operators. Can anyone explain where this value comes from or why this code returns True
? is there a clever way to make the >
operator compare the age without using Person.age
?
>>>from collections import namedtuple
>>>Person = namedtuple('Person', ['age', 'name'])
>>>bob = Person('20', 'bob')
>>>jim = Person('20', 'jim')
>>>bob < jim
True