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
el3ctron
Sat Jul 25 11:06:11 2026
from
Macondo, CO.
via
Telnet
morphBBS
Fri Jul 24 01:11:53 2026
from
Saskatoon, Sk
via
Telnet
Vintagegeek
Wed Jul 22 09:31:30 2026
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Tue Jul 21 16:09:37 2026
from
Swarthmore, Pa
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
318
Nodes:
10 (0
/
10)
Uptime:
04:05:40
Calls:
2,593
Files:
6,270
D/L today:
103 files
(13,166K bytes)
Messages:
483,833
Synchronet Oneliners
Duke@rdbbs Sun Jul 19 08:58:12 2026 I almost made it
morphBBS@rdbbs Mon Jul 20 23:32:53 2026 can you see me?
el3ctron@rdbbs Tue Jul 21 02:46:45 2026 twitter is a oneliner copyy
Vintagegeek@rdbbs Wed Jul 22 09:31:05 2026 Left Right March
morphBBS@rdbbs Fri Jul 24 01:06:24 2026 Movies: The greatest nose job man in the universe & beverly hills