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
Jmay
Fri Mar 13 20:33:12 2026
from
Seattle Wa
via
Telnet
Guest
Thu Mar 12 09:42:43 2026
from
One, Two
via
Telnet
Kat
Wed Mar 11 14:53:54 2026
from
Nashville, Tn
via
Telnet
Guest
Mon Mar 9 23:52:05 2026
from
One, Two
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
295
Nodes:
10 (0
/
10)
Uptime:
11:19:24
Calls:
2,508
Files:
5,704
D/L today:
45 files
(10,098K bytes)
Messages:
462,997
Synchronet Oneliners
Vintagegeek@rdbbs Tue Feb 24 07:04:42 2026 Flyers
Vintagegeek@rdbbs Thu Mar 5 09:15:57 2026 To the Beach
Vintagegeek@rdbbs Fri Mar 6 17:07:01 2026 To The LifeBoats
Vintagegeek@rdbbs Sun Mar 8 10:57:24 2026 Firefly - Serenity
Kat@rdbbs Wed Mar 11 14:52:38 2026 Hello erryone!
Jmay@rdbbs Fri Mar 13 20:32:57 2026 Burning the oatmeal