| ▲ | boxed 5 hours ago | ||||||||||||||||
You think so but then you write a function with a default argument pointing to some variable that is a list and now suddenly the semantics of that are... what? | |||||||||||||||||
| ▲ | codesnik 5 hours ago | parent [-] | ||||||||||||||||
you could just treat argument initialization as an executable expression which is called every time you call a function. If you have a=[], then it's a new [] every time. If a=MYLIST then it's a reference to the same MYLIST. Simple. And most sane languages do it this way, I really don't know why python has (and maintain) this quirk. | |||||||||||||||||
| |||||||||||||||||