News for hackers. Stuff that matters.
Re:Redesigning Python's named tuples by xapata on Friday September 01, 2017 @07:34AM (#15147531)
Are you joking or serious? I can't read your tone without emoji.
Re:Redesigning Python's named tuples by emmelaich on Friday September 01, 2017 @07:52AM (#15147612)
Serious; see coldtea's reply for a fuller explanation.

Or consider (firstname="John", lastname="Doe") vs (lastname="Doe", firstname="John").

I think you'd agree that they're the same.

Re:Redesigning Python's named tuples by rraval on Friday September 01, 2017 @08:26AM (#15147764)
They are the "same" by equality, but that's not the only relevant comparison. Ordering is important if you want lexicographic less than.

Without ordering, you wouldn't be able to sanely run `sorted` on a iterable of namedtuples.

Re:Redesigning Python's named tuples by tomrod on Friday September 01, 2017 @10:55AM (#15148808)
Dumb question from a non-developer: wouldn't using a dict object make more sense if someone wanted an unordered named tuple?
Re:Redesigning Python's named tuples by coldtea on Friday September 01, 2017 @11:43AM (#15149428)
It's not about the storage (besides Python also has order dicts).

Namedtuples are for the convenience of creating a record type (though indeed as others say, treating it as tuple where things expect a tuple is also a benefit).

Re:Redesigning Python's named tuples by xapata on Friday September 01, 2017 @05:13PM (#15152427)
A dict is appropriate for labeled data. Currently unordered, but likely to keep insertion order in v3.7 and later.

Don't call it an unordered namedtuple. That's confusing, because tuples are ordered.

Re:Redesigning Python's named tuples by emmelaich on Tuesday September 05, 2017 @12:11AM (#15172465)
You could order with a custom comparison; specify the columns* to be ordered as in a SQL 'ORDER BY'.
Re:Redesigning Python's named tuples by cocoablazing on Friday September 01, 2017 @08:29AM (#15147780)
I would expect that construction to result in identical behavior for dict() and certainly not anything calling itself a tuple. NamedTuples behaving in the manner you expect violates LSP with respect to tuple().
Re:Redesigning Python's named tuples by xapata on Friday September 01, 2017 @05:15PM (#15152436)
I disagree. As of v3.6, the order of keyword arguments is preserved.