Nп/п : 9 из 100
 От   : Chris Angelico                      2:5075/128        26 сен 23 02:56:39
 К    : On Tue, 26 Sept 2023 at 02:52, Pier                   26 сен 23 20:01:01
 Тема : Re: []=[]
----------------------------------------------------------------------------------
                                                                                 
@MSGID:
<mailman.344.1695661013.23016.python-list@python.org> c0af8349
@REPLY:
<CAPTjJmrhxDDjCC5YUOvjKudC6yBbsZwBechd4OCNVW0WEB2OTw@mail.gmail.com> 41d4db21
@REPLYADDR Chris Angelico <rosuav@gmail.com>
@REPLYTO 2:5075/128 Chris Angelico
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID:
<mailman.344.1695661013.23016.python-list@python.org>
@RFC-References:
<assignment-20230922174933@ram.dialup.fu-berlin.de> <video-20230923083956@ram.dialup.fu-berlin.de> <jlq2uj-of8.ln1@lazy.lzy>
<CAPTjJmrhxDDjCC5YUOvjKudC6yBbsZwBechd4OCNVW0WEB2OTw@mail.gmail.com>
@TZUTC: 1000
@TID: FIDOGATE-5.12-ge4e8b94
On Tue, 26 Sept 2023 at 02:52, Piergiorgio Sartor via Python-list
<python-list@python.org> wrote:
>
> On 23/09/2023 09.41, Stefan Ram wrote:
> > ram@zedat.fu-berlin.de (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
--- FIDOGATE 5.12-ge4e8b94
 * Origin: usenet.network (2:5075/128)
SEEN-BY: 50/109 301/1 467/888 4500/1 5000/111
5001/100 5005/49 5020/715 830
SEEN-BY: 5020/848 1042 4441 12000 5030/49 1081
5054/8 5061/133 5075/128
SEEN-BY: 5080/102 5083/1 444
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх