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
morphBBS
Fri Sep 11 19:31:40 2026
from
Saskatoon, Sk
via
HTTPS
Trevor Walkden
Fri Sep 11 11:21:30 2026
from
Lethbridge, Ab
via
Telnet
Vintagegeek
Fri Sep 11 06:24:12 2026
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Thu Sep 10 09:48:27 2026
from
Swarthmore, Pa
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
318
Nodes:
10 (0
/
10)
Uptime:
20:48:52
Calls:
2,662
Files:
6,469
D/L today:
288 files
(153M bytes)
Messages:
490,009
Synchronet Oneliners
Vintagegeek@rdbbs Tue Aug 25 05:23:45 2026 WINTER IS COMING....PLEASE!
Vintagegeek@rdbbs Wed Aug 26 10:10:56 2026 I Give Up
Windows2kfan@rdbbs Mon Aug 31 06:09:35 2026 hello
Vintagegeek@rdbbs Mon Aug 31 06:48:34 2026 Windows98 was the best
Vintagegeek@rdbbs Wed Sep 2 11:01:44 2026 And Away We Go
Vintagegeek@rdbbs Thu Sep 3 06:41:12 2026 A BLT to go please