|
|
|
|
|
by mickeyp
293 days ago
|
|
I wrote the link and yes it does. Module evaluations reify {}, [], etc. once. That is why people keep making subtle bugs when they do `def foo(a=[]):` unaware that this will in fact not give you a brand new list on every function call. Factory functions like list/tuple/set are function calls and are executed and avoid this problem. Hence why professional python devs default to `None` and check for that and _then_ initialise the list internally in the function body. Adding {/} as empty set is great, sure; but that again is just another reified instance and the opposite of set() the function. |
|