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
Guest
Wed Jul 2 12:37:53 2025
from
Portsmouth, Hampshire
via
Telnet
Dextile
Wed Jul 2 03:20:41 2025
from
Calgary, Ab
via
Telnet
Guest
Tue Jul 1 12:03:32 2025
from
Uk
via
Telnet
Vintagegeek
Tue Jul 1 07:21:13 2025
from
Swarthmore, Pa
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
270
Nodes:
10 (0
/
10)
Uptime:
75:28:16
Calls:
2,219
Calls today:
2
Files:
4,689
D/L today:
399 files
(82,378K bytes)
Messages:
420,651
Synchronet Oneliners
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
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