On Tue, Aug 9, 2016 at 12:29 AM Guido van Rossum <gu...@python.org> wrote:
> On Mon, Aug 8, 2016 at 2:11 PM, אלעזר <elaz...@gmail.com> wrote: > >> Feels like named parameters are better off being an OrderedDict in the >> first place. >> > > PEP 468. > > Sorry, I should have read this PEP before. > NamedTuple pushes OrderedDict to become kind of builtin. >> > > Why? Having both in the collections module is good enough. > What I meant in becoming builtin is not the accessibility of the name, but the parallel incremental support of namedtuple, OrderedDict and (as I find out) order of **kwargs. In much the same way that class is made out of dict (and keeps one), namedtuple is an OrderedDict (and keeps one). Much like dict has a constructor `dict(a=1, b=2.0)` and a literal `{'a' : 1, 'b' : 2.0}`, OrderedDict has its OrderedDict(a=1, b=2.0) and should have the literal ('a': 1, 'b': 2.0). Replace 1 and 2 with int and float and you get a very natural syntax for a NamedTuple that is the type of a matching OrderedDict. And in my mind, the requirement for type names matches nicely the enforcement of immutability. Continuing this thought, the annotations for the class is actually its structural type. It opens the door for future requests for adding e.g. an operator for structural equivalence. This is all very far from the current language, so it's only thoughts and not really ideas; probably does not belong here. Sorry about that. ~Elazar
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/