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

Lennart Regebro regebro at gmail.com
Mon Jul 27 18:23:04 CEST 2015


On Mon, Jul 27, 2015 at 6:02 PM, Sven R. Kunze <srkunze at mail.de> wrote:
> On 27.07.2015 17:45, Lennart Regebro wrote:
>>
>> On Mon, Jul 27, 2015 at 5:30 PM, Sven R. Kunze <srkunze at mail.de> wrote:
>>>
>>> I cannot follow. There is nothing about 'await' that tells me it can only
>>> be
>>> used with coroutines. I need to memorize that fact, too.
>>
>> No, because you get a syntax error when you use it incorrectly, so you
>> don't need to memorize that.
>> But here it works only with specific types.
>
> What's the difference?

Well, for one, one is a runtime error and the other is not.

>> Well, that is going to be the case now as well, you can't get away from
>> that.
>
> Is it? I don't think so. There are many case where this is not the case.

No, there isn't. The proposed syntax will work if the variable is a
mapping, but fail if it is any other type. The type will *only* be
known once it's time to execute that statement.

But sure, the same goes for "for x in y:" really. That only works with
iterables. So maybe this isn't a problem.


More information about the Python-ideas mailing list