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
Connor Finlayson
Wed Sep 23 00:17:04 2026
from
Calgary, Alberta
via
Telnet
Vintagegeek
Tue Sep 22 09:27:28 2026
from
Swarthmore, Pa
via
Telnet
Trevor Walkden
Fri Sep 18 11:49:03 2026
from
Lethbridge, Ab
via
Telnet
Vintagegeek
Wed Sep 16 06:22:48 2026
from
Swarthmore, Pa
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
319
Nodes:
10 (0
/
10)
Uptime:
03:01:34
Calls:
2,670
Files:
6,522
D/L today:
62 files
(26,421K bytes)
Messages:
491,307
Synchronet Oneliners
Vintagegeek@rdbbs Tue Aug 25 05:23:45 2026 WINTER IS COMING....PLEASE!
Vintagegeek@rdbbs Wed Aug 26 10:10:56 2026 I Give Up
Windows2kfan@rdbbs Mon Aug 31 06:09:35 2026 hello
Vintagegeek@rdbbs Mon Aug 31 06:48:34 2026 Windows98 was the best
Vintagegeek@rdbbs Wed Sep 2 11:01:44 2026 And Away We Go
Vintagegeek@rdbbs Thu Sep 3 06:41:12 2026 A BLT to go please