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
Deepend
Mon May 25 15:48:21 2026
from
Calgary, Ab
via
HTTPS
Darknetgirl
Mon May 25 04:31:27 2026
from
London
via
Telnet
Lord Jord
Sat May 23 15:08:49 2026
from
Olds, Alberta
via
Telnet
H333d
Sat May 23 11:59:31 2026
from
Olds, Alberta
via
HTTPS
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
312
Nodes:
10 (0
/
10)
Uptime:
00:11:59
Calls:
2,557
Calls today:
1
Files:
6,003
D/L today:
54 files
(20,717K bytes)
Messages:
473,789
Synchronet Oneliners
Duke@rdbbs Sat May 16 10:42:25 2026 Duke is Here
Duke@rdbbs Sun May 17 09:24:34 2026 Fixer Upper - Chip and Jojo
H333d@rdbbs Sun May 17 13:40:12 2026 im feeling #green today
Vintagegeek@rdbbs Mon May 18 11:28:35 2026 Green It Is
Underlord@rdbbs Tue May 19 00:36:34 2026 just set up win3.1 on my retro system, feels like childhood
Lord Jord@rdbbs Sat May 23 15:08:21 2026 hello from olds!!