[Python-ideas] Syntax for key-value iteration over mappings

Pierre Quentel pierre.quentel at gmail.com
Wed Jul 29 08:22:57 CEST 2015

2015-07-28 19:39 GMT+02:00 Petr Viktorin <encukou at gmail.com>:

> On Mon, Jul 27, 2015 at 6:23 AM, Ben Finney <ben+python at benfinney.id.au>
> wrote:
> On the other hand, parenthesizing it makes it look like an expression,
> that is, something that can be part of a larger expression.
> Key/value unpacking only works as a target of a "for".

If the proposal was accepted for "for k:v in iterable" then I suppose that "if
k:v in iterable" would also be valid, meaning that for a dict, there is a
pair (k, v) such that _dict[k] = v, and for a list that there is an index k
such that _list[k] = v.

for k:v in iterable:
    assert k:v in iterable

> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150729/6d2b666c/attachment.html>

More information about the Python-ideas mailing list