Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: []=[]

27 views
Skip to first unread message

Alan Bawden

unread,
Sep 22, 2023, 7:27:39 PM9/22/23
to
r...@zedat.fu-berlin.de (Stefan Ram) writes:

[]=[]

(Executes with no error.)

So does:

() = ""

Greg Ewing

unread,
Sep 22, 2023, 11:42:14 PM9/22/23
to
On 23/09/23 4:51 am, Stefan Ram wrote:
> []=[]
>
> (Executes with no error.)

#####
[]=[]
( 1 )
#\_/#

(Executes with no error.)

--
Greg

Piergiorgio Sartor

unread,
Sep 23, 2023, 6:20:34 AM9/23/23
to
On 23/09/2023 09.41, Stefan Ram wrote:
> r...@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... :-)

bye,

--

piergiorgio

Chris Angelico

unread,
Sep 25, 2023, 12:57:15 PM9/25/23
to
On Tue, 26 Sept 2023 at 02:52, Piergiorgio Sartor via Python-list
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

Rob Cliffe

unread,
Sep 26, 2023, 11:40:09 AM9/26/23
to
It's not a bug, it's an empty unpacking.
Just as you can write
    [A,B] = [1,2] # Sets A to 1, B to 2
Best wishes
Rob Cliffe
0 new messages