Frage im Vorstellungsgespräch bei Demonware

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

Antworten zu Vorstellungsgespräch

Anonym

12. Juni 2014

Neither.

1

Anonym

21. Juli 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