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 Oct 16 07:49:26 2025
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Thu Oct 16 04:34:33 2025
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Mon Oct 13 18:21:14 2025
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Sun Oct 12 08:38:03 2025
from
Swarthmore, Pa
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
279
Nodes:
10 (0
/
10)
Uptime:
00:38:00
Calls:
2,394
Calls today:
2
Files:
5,126
D/L today:
62 files
(28,520K bytes)
Messages:
435,150
Synchronet Oneliners
Vintagegeek@rdbbs Thu Sep 25 09:47:55 2025 The Price is Right
Vintagegeek@rdbbs Thu Oct 2 09:15:49 2025 Next
Vintagegeek@rdbbs Fri Oct 3 10:18:45 2025 Gotta gotra gotta - make a hole
Dev00903@rdbbs Mon Oct 6 04:48:23 2025 hello guys
Dev00903@rdbbs Mon Oct 6 04:48:48 2025 how it works this?
Vintagegeek@rdbbs Fri Oct 10 11:47:51 2025 Is it 1984 ?