3 ms·
The fact that "methods" is somehow kept defined in the scope of the function and preserved when you call it again and isn't always reinitialized to [] is just d
by pmarreck 10y ago
The fact that "methods" is somehow kept defined in the scope of the function and preserved when you call it again and isn't always reinitialized to [] is just dumb. No wonder this was a bug, who the hell would see that and how is this "feature" ever useful except to create bugs?
- Oxitendwe 10y agoIt's absolutely insane that this is apparently the expected behavior. It makes no sense whatsoever except to give people who know this an ego boost when they can successfully work around Python's unintuitive semantics while inexperienced people cannot. It completely breaks functions, the most fundamental unit of encapsulation and abstraction in every modern programming language.
- pmarreck 10y agoIt's surprising how few languages actually support anonymous functions with closures properly. Not to plug my 2 favorites that do (Ruby and Elixir/Erlang) or anything...
- deleted 10y ago[deleted]