[Python-ideas] namedtuple literals [Was: RE a new namedtuple]

David Mertz mertz at gnosis.cx
Mon Jul 31 01:41:35 EDT 2017

> But most of the time you always have the same attributes in the same order
> (think of reading a CSV for example), and this would be just a normal
> tuple, but with custom names for the indexes.

You apparently live in a halcyon world of data cleanliness where CSV data
is so well behaved.

In my world, I more typically deal with stuff like



I'm likely to define different namedtuples for dealing with this:

    NameSalAge = namedtuple('NSA','name salary age')
    NameAgeSal = namedtuple('NAS','name age salary')

Then later, indeed, I might ask:

    if employee1.salary == employee2.salary: ...

And this would work even though I got the data from the different formats.

Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170730/08e70681/attachment.html>

More information about the Python-ideas mailing list