On Fri, Oct 23, 2020 at 5:43 PM David Mertz <me...@gnosis.cx> wrote: > On Fri, Oct 23, 2020, 5:44 AM Alex Hall > >> (Heretical question: do we *really* need to distinguish it in syntax? >> Iterator unpacking a dict seems like a dumb idea, I wouldn't be sad if we >> broke compatibility there) >> > > Breaking millions of lines of idiomatic code seems like a bad idea. > > a, b, c = mydict > > Mary not be so very common, but this is ubiquitous: > > for k in mydict: ... >
What I mean is that maybe `a, b = foo` could first test if `foo` is a mapping, use mapping unpacking if it is, otherwise fall back to regular iterable unpacking. So dicts would remain iterable, but that wouldn't feature in unpacking. Then there wouldn't be a change in syntax, or in other kinds of iteration, just a change in what happens if you unpack a dict.
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/R2UXNAMYREAX25YCHCQA357JGVPVP4ZX/ Code of Conduct: http://python.org/psf/codeofconduct/