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
Darknetgirl
Tue Jul 15 11:31:42 2025
from
London
via
Telnet
Darknetgirl
Tue Jul 15 10:41:39 2025
from
London
via
Telnet
Darknetgirl
Tue Jul 15 10:07:30 2025
from
London
via
Telnet
Dextile
Mon Jul 14 20:43:21 2025
from
Calgary, Ab
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
272
Nodes:
10 (0
/
10)
Uptime:
03:58:03
Calls:
2,252
Calls today:
3
Files:
4,760
D/L today:
26 files
(12,511K bytes)
Messages:
422,517
Synchronet Oneliners
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
Vintagegeek@rdbbs Sat Jun 7 17:12:17 2025 Mars is busy today
Vintagegeek@rdbbs Tue Jun 24 16:54:23 2025 Leaving Mars at 17:15 on to Jupiter
Guest@rdbbs Wed Jul 2 12:37:39 2025 This is the good stuff
Vintagegeek@rdbbs Sat Jul 12 08:53:00 2025 Heading to the Scottish Open