
On 07/27/2017 06:24 PM, Stephen J. Turnbull wrote:
Ethan Furman writes:
Tuples, named or otherwise, are positional first -- order matters. Specifying
point = ntuple(y=2, x=-3)
and having point[0] == 3 is going to be bizarre. This will be a source for horrible bugs.
I don't see how you get that?
How I get the point[0] == 3? The first definition of an ntuple had the order as x, y, and since the proposal is only comparing field names (not order), this (y, x) ntuple ends up being reversed to how it was specified.
Anyway, I expect that ntuples will *very* frequently be *written* in an order-dependent (and probably highly idiomatic) way, and *read* using attribute notation:
Sure, but they can also be unpacked, and order matters there. Also, as D'Aprano pointed out, if the first instance of an ntuple has the fields in a different order than expected, all subsequent ntuples that are referenced in an order-dependent fashion will be returning data from the wrong indexes. -- ~Ethan~