Sollicitatievraag bij Demonware

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

Antwoorden op sollicitatievragen

Anoniem

12 jun 2014

Neither.

1

Anoniem

21 jul 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