MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1xfxtnx/i_love_python/19rp33umhmjk5/?context=3
r/programminghorror • u/nakurtag • Oct 26 '26
81 comments sorted by
View all comments
Show parent comment
2
Here's a single change to the posted code that kinda shows what actually happens.
my_list = [] def add(v, items=my_list): items.append(v) return items print(add(1)) print(add(2))
1 u/bigorangemachine Oct 26 '26 Ya I test in JS and JS will do this.. oddly enough they are so similar JS didn't do the thing OP posted about.Surprised about that one... but it makes sense.
1
Ya I test in JS and JS will do this.. oddly enough they are so similar JS didn't do the thing OP posted about.
Surprised about that one... but it makes sense.
View all comments
Show parent comment
2
u/lolcrunchy Oct 26 '26
Here's a single change to the posted code that kinda shows what actually happens.