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
Vintagegeek
Thu May 14 06:46:33 2026
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Wed May 13 05:07:05 2026
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Tue May 12 12:24:50 2026
from
Swarthmore, Pa
via
Telnet
Rwe
Mon May 11 13:28:11 2026
from
Europe
via
HTTPS
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
308
Nodes:
10 (0
/
10)
Uptime:
07:26:21
Calls:
2,546
Files:
5,963
D/L today:
74 files
(47,972K bytes)
Messages:
473,320
Synchronet Oneliners
Tsukaj@rdbbs Tue Mar 17 22:27:28 2026 hell yeah this is so cool
Ecjonas@rdbbs Tue Mar 31 06:08:47 2026 Fedora be nice, i think
Vintagegeek@rdbbs Wed Apr 1 09:46:05 2026 Happy April 1st