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
Deepend
Fri Nov 20 00:13:31 2026
from
Calgary, Ab
via
HTTPS
Vintagegeek
Thu Nov 19 11:14:40 2026
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Tue Nov 17 06:51:08 2026
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Mon Nov 16 15:18:32 2026
from
Swarthmore, Pa
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
326
Nodes:
10 (0
/
10)
Uptime:
81:01:23
Calls:
2,755
Files:
6,698
D/L today:
12 files
(10,130K bytes)
Messages:
498,022
Synchronet Oneliners
Dundee@rdbbs Mon Oct 19 16:38:50 2026 The Dude abides...
Vintagegeek@rdbbs Sun Nov 1 13:54:14 2026 November is here
Vintagegeek@rdbbs Fri Nov 6 11:28:18 2026 His r Hers Golf Clubs
Vintagegeek@rdbbs Sun Nov 15 08:19:35 2026 back online
Vintagegeek@rdbbs Mon Nov 16 15:18:25 2026 picit0
Vintagegeek@rdbbs Tue Nov 17 06:50:40 2026 MegaSlots and Lemonade