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
Dextile
Thu Jun 5 05:51:52 2025
from
Calgary, Ab
via
Telnet
Nightfox
Wed Jun 4 14:14:03 2025
from
Beaverton, Or
via
Telnet
Nightfox
Wed Jun 4 13:39:48 2025
from
Beaverton, Or
via
SSH
Darknetgirl
Wed Jun 4 13:35:20 2025
from
London
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
269
Nodes:
10 (0
/
10)
Uptime:
84:57:11
Calls:
2,163
Calls today:
1
Files:
4,566
D/L today:
18 files
(9,997K bytes)
Messages:
419,702
Synchronet Oneliners
Vintagegeek@rdbbs Mon Apr 7 15:00:43 2025 Britbox
Vintagegeek@rdbbs Tue Apr 29 06:11:59 2025 My life is Murder TV
Vintagegeek@rdbbs Sat May 3 05:08:46 2025 Go Stampede
Darknetgirl@rdbbs Tue May 6 02:09:48 2025 Greetings from London/Milan. Getting back to real stuff
Vintagegeek@rdbbs Wed May 14 09:34:53 2025 Greetings from the ISS
Guest@rdbbs Sun May 18 09:30:17 2025 greetings from Poland / Europe