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
Tue Mar 24 13:59:20 2026
from
Oakland, Ca
via
Telnet
realjameswilliam
Tue Mar 24 05:40:41 2026
via
HTTPS
Guest
Thu Mar 19 21:02:10 2026
from
One, Two
via
Telnet
Deepend
Wed Mar 18 08:26:50 2026
from
Calgary, Ab
via
HTTPS
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
297
Nodes:
10 (0
/
10)
Uptime:
57:52:16
Calls:
2,511
Files:
5,761
D/L today:
130 files
(32,514K bytes)
Messages:
465,343
Synchronet Oneliners
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
Tsukaj@rdbbs Tue Mar 17 22:27:28 2026 hell yeah this is so cool