Re:Python Anti-Pattern
by petercooper on Wednesday September 15, 2021 @09:42AM
(#28538918)
As a Rubyist who only uses Python casually, it's neat to learn this difference! You can write very similar code in Ruby but such default objects appear to be created fresh on initialization avoiding the problem.
[ Parent
| on HN ]
Re:Python Anti-Pattern
by dragonwriter on Wednesday September 15, 2021 @05:30PM
(#28544634)
OTOH, Ruby has a very similar footgun with mutable defaults, just with default values of Hashes, not default method arguments.