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
Fri Mar 6 10:38:37 2026
from
Swarthmore, Pa
via
Telnet
Deepend
Thu Mar 5 15:02:50 2026
from
Calgary, Ab
via
HTTPS
Vintagegeek
Thu Mar 5 09:17:33 2026
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Wed Mar 4 19:31:00 2026
from
Swarthmore, Pa
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
293
Nodes:
10 (1
/
9)
Uptime:
29:57:37
Calls:
2,500
Calls today:
1
Files:
5,660
D/L today:
153 files
(14,502K bytes)
Messages:
461,520
Synchronet Oneliners
Vintagegeek@rdbbs Tue Jan 13 13:09:57 2026 Look At That Moon
Deepend@rdbbs Mon Jan 26 00:12:58 2026 I'd have to go outside.. lol
Denn@rdbbs Sat Feb 7 14:17:58 2026 I'm suprised you didn't hook your wall up as interBBS.
Vintagegeek@rdbbs Sun Feb 15 14:57:42 2026 Go Flames
Vintagegeek@rdbbs Tue Feb 24 07:04:42 2026 Flyers
Vintagegeek@rdbbs Thu Mar 5 09:15:57 2026 To the Beach