On Tue, 19 Jun 2018 11:52:22 +0100, Bart wrote: > On 19/06/2018 11:33, Steven D'Aprano wrote: >> On Tue, 19 Jun 2018 10:19:15 +0100, Bart wrote: >> >>> * Swap(x,y) (evaluate each once unlike a,y=y,x) >> >> Sigh. Really? You think x,y = y,x evaluates x and y twice? > > Yes.
Well, you would be wrong. [steve@ando ~]$ python3.5 -c "import dis; dis.dis('x, y = y, x')" 1 0 LOAD_NAME 0 (y) 3 LOAD_NAME 1 (x) 6 ROT_TWO 7 STORE_NAME 1 (x) 10 STORE_NAME 0 (y) 13 LOAD_CONST 0 (None) 16 RETURN_VALUE > Try: [snip complex example] Why would I try that? You made a claim that x, y = y, x evaluates x and y twice. You didn't say anything about calling a function twice. Of course if you call a function twice, the function gets called twice. What does your language do? Shifting the goals posts is not a nice thing to do Bart. You made a claim about swapping two named variables, not one about multiple function calls. -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson -- https://mail.python.org/mailman/listinfo/python-list