On 19 June 2015 at 22:56, Martin Teichmann <lkb.teichm...@gmail.com> wrote:
> to get something out of the database. But getting something in, I have
> to write something like
>
>     await table.set(key, value)
>
> It would be cool if I could just write
>
>     await table[key] = value

You've introduced an ambiguity here, though, as you're applying
async/await to a statement without a leading keyword.

In "await expr" it's clear "expr" is expected to produce an Awaitable,
and the await expression waits for it.

In "async for" and "async with" it's clearly a modifier on the
respective keyword, and hence serves as a good mnemonic for switching
to the asynchronous variants of the relevant protocols.

But what does an "asynchronous assignment" do? Do we need __asetattr__
and __asetitem__ protocols, and only allow it when the target is a
subscript operation or an attribute? What if we're assigning to
multiple targets, do the run in parallel? How is tuple unpacking
handled? How is augmented assignment handled?

If we allow asynchronous assignment, do we allow asynchronous deletion as well?

As you start working through some of those possible implications of
offering an asynchronous assignment syntax, the explicit method based
"await table.set(key, value)" construct may not look so bad after all
:)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to