Pergunta de entrevista da empresa Demonware

Is Python pass-by-reference or pass-by-value?

Respostas da entrevista

Sigiloso

12 de jun. de 2014

Neither.

1

Sigiloso

21 de jul. de 2016

An actually informative answer, for those who are interested: Python is pass-by-object-reference ("object references are passed by value"). It works like pass-by-val in that if you reassign the variable in the function (make it point to something else), the variable will still have the old value when the function returns. But if you modify the object in the function (such as adding to a list) it will reflect that once the function returns.

1