On 26 July 2017 at 03:49, MRAB <[email protected]> wrote:
> I don't see how they could be compatible with tuples because the positions
> aren't fixed. You would need a NamedTuple where the type specifies the
> order.
Python 3.6+ guarantees that keyword-argument order is preserved in the
namespace passed to the called function.
This means that a function that only accepts **kwargs can reliably
check the order of arguments used in the call, and hence tell the
difference between:
ntuple(x=1, y=2)
ntuple(y=1, x=2)
So because these are implicitly typed, you *can't* put the arguments
in an arbitrary order - you have to put them in the desired field
order, or you're going to accidentally define a different type.
If that possibility bothers someone and they want to avoid it, then
the solution is straightforward: predefine an explicit type, and use
that instead of an implicitly defined one.
Cheers,
Nick.
--
Nick Coghlan | [email protected] | Brisbane, Australia
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/