Question d’entretien chez Demonware

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

Réponses aux questions d'entretien

Utilisateur anonyme

12 juin 2014

Neither.

1

Utilisateur anonyme

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