On Fri, Oct 23, 2020 at 6:19 AM Tin Tvrtković
Hi,
first of all, I'm a big fan of the changes being proposed here since in my code I prefer the 'union' style of logic over the OO style.
I was curious, though, if there are any plans for the match operator to support async stuff. I'm interested in the problem of waiting on multiple asyncio tasks concurrently, and having a branch of code execute depending on the task.
Currently this can be done by using asyncio.wait, looping over the done set and executing an if-else chain there, but this is quite tiresome. Go has a select statement (https://tour.golang.org/concurrency/5) that looks like this:
select { case <-ch1: fmt.Println("Received from ch1") case <-ch2: fmt.Println("Received from ch2") }
Speaking personally, this is a Go feature I miss a lot when writing asyncio code. The syntax is similar to what's being proposed here. Although it could be a separate thing added later, async match, I guess.
Hadn't seen this before. You could propose this as a follow-up for 3.11. But aren't Go channels more like asyncio Queues? I guess we'd need way more in terms of a worked-out example (using asyncio code, not Go code). -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...