[Python-ideas] Anonymous namedtuples

Steven D'Aprano steve at pearwood.info
Tue Apr 19 09:24:34 EDT 2016


On Tue, Apr 19, 2016 at 01:47:09PM +0100, Paul Moore wrote:
> On 19 April 2016 at 13:34, Joseph Martinot-Lagarde
> <contrebasse at gmail.com> wrote:
> > But I still think that my proposal has some value outside of SimpleNamespace. :)
> 
> The biggest issue is likely to be that the added value doesn't justify
> the cost of new syntax, and a language change. 

I think there are more problems with the proposal than just "not useful 
enough". See my previous post.

> On the other hand,
> functions preserving the order of keyword arguments (which would allow
> you to write a cleaner factory function) is probably a change with
> wider value, as well as being less intrusive (it's a semantic change,
> but there's no change in syntax) and so may be more likely to get
> through.

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.



-- 
Steve


More information about the Python-ideas mailing list