From cosarara@cosarara@tilde.club to tilde.python on Wed Dec 22 09:56:19 2021
Run the following code:
a = a[0] = [0]
print(a)
Do you think it will error out on the first line? Can you explain how it works? Think about it, then read below for the answer:
Chained assignment in python takes the rightmost element and assigns
left to right, such that the statement boils down to:
tmp = [0]
a = tmp
a[0] = tmp
Thus creating a as a list of one element, that element being itself.
This is probably the most confusing and satisfyingly evil python trick I
know. Do you know other interesting tricks?
--- Synchronet 3.19a-Linux NewsLink 1.113
Who's Online
Recent Visitors
Dextile
Sat Jul 5 05:04:46 2025
from
Calgary, Ab
via
Telnet
Dextile
Fri Jul 4 03:13:54 2025
from
Calgary, Ab
via
Telnet
Dextile
Thu Jul 3 23:38:08 2025
from
Calgary, Ab
via
Telnet
Dextile
Thu Jul 3 19:55:19 2025
from
Calgary, Ab
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
270
Nodes:
10 (0
/
10)
Uptime:
25:59:00
Calls:
2,223
Calls today:
1
Files:
4,714
D/L today:
32 files
(10,001K bytes)
Messages:
422,469
Synchronet Oneliners
Darknetgirl@rdbbs Tue May 6 02:09:48 2025 Greetings from London/Milan. Getting back to real stuff
Vintagegeek@rdbbs Wed May 14 09:34:53 2025 Greetings from the ISS
Guest@rdbbs Sun May 18 09:30:17 2025 greetings from Poland / Europe
Vintagegeek@rdbbs Sat Jun 7 17:12:17 2025 Mars is busy today
Vintagegeek@rdbbs Tue Jun 24 16:54:23 2025 Leaving Mars at 17:15 on to Jupiter
Guest@rdbbs Wed Jul 2 12:37:39 2025 This is the good stuff