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
Tue Nov 10 17:36:46 2026
from
Swarthmore, Pa
via
Telnet
morphBBS
Mon Nov 9 14:16:50 2026
from
Saskatoon, Sk
via
HTTPS
morphBBS
Mon Nov 9 02:15:46 2026
from
Saskatoon, Sk
via
HTTPS
morphBBS
Sun Nov 8 14:14:40 2026
from
Saskatoon, Sk
via
HTTPS
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
326
Nodes:
10 (0
/
10)
Uptime:
06:55:09
Calls:
2,751
Files:
6,660
D/L today:
61 files
(24,811K bytes)
Messages:
496,833
Synchronet Oneliners
User Fx@rdbbs Sun Oct 4 21:01:03 2026 idek. thank you, from hashnix.club peace. ~ufx
Dustman@rdbbs Wed Oct 7 11:32:39 2026 Howdy all :)
Vintagegeek@rdbbs Wed Oct 14 10:53:35 2026 The Price is Wrong Now
Dundee@rdbbs Mon Oct 19 16:38:50 2026 The Dude abides...
Vintagegeek@rdbbs Sun Nov 1 13:54:14 2026 November is here
Vintagegeek@rdbbs Fri Nov 6 11:28:18 2026 His r Hers Golf Clubs