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 Nov 16 08:08:08 2025
from
Swarthmore, Pa
via
Telnet
Guest
Sun Nov 16 00:57:07 2025
from
No
via
Telnet
Vintagegeek
Sat Nov 15 11:07:35 2025
from
Swarthmore, Pa
via
Telnet
Lisawilliam
Wed Nov 12 22:28:04 2025
via
HTTPS
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
283
Nodes:
10 (0
/
10)
Uptime:
04:16:54
Calls:
2,421
Calls today:
2
Files:
5,216
D/L today:
149 files
(39,303K bytes)
Messages:
439,190
Synchronet Oneliners
Witness@rdbbs Sun Oct 26 00:03:42 2025 Is this the BBS yet?
Guest@rdbbs Mon Nov 3 13:54:14 2025 i'm very confused, what happened to bbj :'(
Vintagegeek@rdbbs Tue Nov 4 05:21:46 2025 Play MegaSlots