• []=[]

    From Stefan Ram@21:1/5 to All on Fri Sep 22 16:51:09 2023
    []=[]

    (Executes with no error.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alan Bawden@21:1/5 to All on Fri Sep 22 19:27:14 2023
    ram@zedat.fu-berlin.de (Stefan Ram) writes:

    []=[]

    (Executes with no error.)

    So does:

    () = ""

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Ewing@21:1/5 to Stefan Ram on Sat Sep 23 15:41:47 2023
    On 23/09/23 4:51 am, Stefan Ram wrote:
    []=[]

    (Executes with no error.)

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

    (Executes with no error.)

    --
    Greg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Stefan Ram on Sat Sep 23 07:41:53 2023
    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.")

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Piergiorgio Sartor@21:1/5 to Stefan Ram on Sat Sep 23 12:18:59 2023
    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... :-)

    bye,

    --

    piergiorgio

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Angelico@21:1/5 to python-list@python.org on Tue Sep 26 02:56:39 2023
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rob Cliffe@21:1/5 to Greg Ewing via Python-list on Sun Sep 24 23:42:18 2023
    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

    On 23/09/2023 04:41, Greg Ewing via Python-list wrote:
    On 23/09/23 4:51 am, Stefan Ram wrote:
    []=[]

       (Executes with no error.)

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

    (Executes with no error.)


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)