On Tue, Nov 28, 2017 at 2:35 AM, Steven D'Aprano <st...@pearwood.info> wrote: > In this case, there is a small but real benefit to counting the > assignment targets and being explicit about the number of items to > slice. Consider an extension to this "non-consuming" unpacking that > allowed syntax like this to pass silently: > > a, b = x, y, z > > That ought to be a clear error, right? I would hope you don't think that > Python should let that through. Okay, now we put x, y, z into a list, > then unpack the list: > > L = [x, y, z] > a, b = L > > That ought to still be an error, unless we explicity silence it. One way > to do so is with an explicit slice: > > a, b = L[:2]
I absolutely agree with this for the default case. That's why I am ONLY in favour of the explicit options. So, for instance: a, b = x, y, z # error a, b, ... = x, y, z # valid (evaluates and ignores z) ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/