[Python-ideas] Anonymous namedtuples

Joseph Martinot-Lagarde contrebasse at gmail.com
Tue Apr 19 16:38:06 EDT 2016

> It's a pretty big semantic change though. As I point out in my previous 
> post, at the moment we can be sure that changing the order of keyword 
> arguments does not change anything: spam(a=1, b=2) and spam(b=2, a=1) 
> will always have the same semantics. Making keyword arguments ordered 
> will break that assumption, and even if it doesn't break any existing 
> code, it will make it harder to reason about future code. No more can 
> you trust that the order of keyword arguments will have no effect on the 
> result of calling a function.
> I don't see the current behaviour of keyword arguments as a limitation, 
> I see it as a feature. I don't need to care about the order of keyword 
> arguments, only their names.
I think I finally understand your concern about keeping the order of
keywords arguments. Most of the time it wouldn't matter but it can
potentially lead to very surprising behavior. Maybe the fact that we're all
consenting adults can help ?

However in my proposal there is no function call, even if the syntax is
similar. The order of the fields has the same significance as in a
namedtuple, but it's another (easier) way to set them.
It's also why I proposed an evolution to use it in __getitem__ also, which
already doesn't behave like a standard function call either.


More information about the Python-ideas mailing list