| ▲ | codesnik 5 hours ago | |||||||
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. | ||||||||
| ▲ | 1718627440 an hour ago | parent [-] | |||||||
What are the semantics of the following:
Should it create a copy of b every time the function is invoked? If you want that right now, you can just call b.copy (), when you always create that copy, then you can not implement the current choice.Should the semantic of this be any different? :
Now imagine a: | ||||||||
| ||||||||