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
Guest
Mon Dec 15 21:09:57 2025
from
Guest, Ca
via
Telnet
Guest
Sat Dec 13 23:47:02 2025
from
Louisville, Kentucky
via
Telnet
Guest
Sat Dec 13 23:43:56 2025
from
Sydney, Au
via
Telnet
Bookdragon
Sat Dec 13 12:08:33 2025
from
Ca
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
288
Nodes:
10 (0
/
10)
Uptime:
06:22:13
Calls:
2,453
Files:
5,334
D/L today:
39 files
(25,323K bytes)
Messages:
445,182
Synchronet Oneliners
Pedro Herzensbuch@rdbbs Sat Dec 6 14:51:28 2025 Van a pasar cosas
Vintagegeek@rdbbs Sun Dec 7 13:30:36 2025 Merry Christmas
Vintagegeek@rdbbs Wed Dec 10 08:04:26 2025 M E R R Y C H R I S T M A S
Guest@rdbbs Sat Dec 13 23:46:34 2025 :)
Guest@rdbbs Mon Dec 15 21:08:57 2025 merry christmas from joshua tree
Deepend@rdbbs Tue Dec 16 21:40:53 2025 Merry Christmas!