On Tue, 26 Sept 2023 at 02:52, Piergiorgio Sartor via Python-list <
[email protected]> wrote:
On 23/09/2023 09.41, Stefan Ram wrote:
[email protected] (Stefan Ram) writes:
[]=[]
I was watching a video of a David Beazley talk "Python
Concurrency From the Ground Up" , where he wrote
can_recv, can_send, [] = select(recv_wait, send_wait, [])
. Later, he clarified that he actually wanted to write
can_recv, can_send, _ = select(recv_wait, send_wait, [])
and that he was surprised how the "[]" gave no error.
("I wonder why that works.")
If you try:
[] = [1]
and check the error, it will be clear how it works.
Maybe not why... :-)
Note that the reason it gives no error is that select() returned an
empty iterable as the third value. And you can be sure that it will
ALWAYS return an empty iterable, because select() returns three values
that correspond to the three parameters, and are subsets of them -
that is to say, everything in can_recv must have previously been in
recv_wait, and everything in can_send must have been in send_wait.
Since the third (waiting for exceptional conditions) was empty, there
can't ever be anything to return, and so [] will work, and unpack zero elements.
ChrisA
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)