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
Vintagegeek
Sun Sep 7 11:01:26 2025
from
Swarthmore, Pa
via
Telnet
Dextile
Sun Sep 7 08:31:53 2025
from
Calgary, Ab
via
Telnet
Vintagegeek
Sun Sep 7 05:11:25 2025
from
Swarthmore, Pa
via
Telnet
Darknetgirl
Sat Sep 6 12:08:09 2025
from
London
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
278
Nodes:
10 (0
/
10)
Uptime:
15:06:45
Calls:
2,357
Calls today:
3
Files:
4,990
D/L today:
218 files
(61,623K bytes)
Messages:
428,728
Synchronet Oneliners
Vintagegeek@rdbbs Tue Aug 12 07:14:02 2025 Cass
Vintagegeek@rdbbs Fri Aug 22 05:53:33 2025 OpenWide
Serpentchain@rdbbs Tue Sep 2 20:21:16 2025 Glowing Apple Hums,
Serpentchain@rdbbs Tue Sep 2 20:21:26 2025 Telnet Whispers Through The Night,
Serpentchain@rdbbs Tue Sep 2 20:21:35 2025 BBS Dreams In Code.
Vintagegeek@rdbbs Wed Sep 3 11:26:08 2025 Heading to Banf f f