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
Sun Jun 28 10:34:10 2026
from
Swarthmore, Pa
via
Telnet
Deepend
Fri Jun 26 10:17:21 2026
from
Calgary, Ab
via
HTTP
Vintagegeek
Thu Jun 25 19:54:41 2026
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Thu Jun 25 17:45:44 2026
from
Swarthmore, Pa
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
315
Nodes:
10 (0
/
10)
Uptime:
100:15:01
Calls:
2,573
Files:
6,156
D/L today:
43 files
(18,084K bytes)
Messages:
478,445
Synchronet Oneliners
Lord Jord@rdbbs Sat May 23 15:08:21 2026 hello from olds!!
Vintagegeek@rdbbs Sun May 31 06:45:26 2026 No one cares anymore. Congress is a Sinkhole
Regen@rdbbs Tue Jun 9 09:36:17 2026 Knowledge is Good
Vintagegeek@rdbbs Wed Jun 10 15:01:58 2026 Hey Crazy Man. Do a little dance...
Vintagegeek@rdbbs Thu Jun 11 10:12:20 2026 Let the dogs out !!
Vintagegeek@rdbbs Thu Jun 25 19:54:33 2026 The Discovery of Witches