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 May 7 02:46:01 2024
from
Swarthmore, Pa
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
241
Nodes:
10 (0
/
10)
Uptime:
67:42:10
Calls:
1,471
Calls today:
1
Files:
3,380
Messages:
359,453
Synchronet Oneliners
Vintagegeek@rdbbs Sun Apr 28 05:40:04 2024 go giants
Vintagegeek@rdbbs Sun Apr 28 13:42:10 2024 Go Phillies
Vintagegeek@rdbbs Mon Apr 29 04:53:15 2024 Go Canucks
Vintagegeek@rdbbs Wed May 1 05:32:11 2024 Oh God Its already May
Doc@rdbbs Sun May 5 19:05:31 2024 Hey everyone! Good to be here
Vintagegeek@rdbbs Mon May 6 06:29:25 2024 WELCOME -