Python - Parameter Pass by Reference

preview_player
Показать описание
Python - Parameter Pass by Reference
Watch More Videos at:
Lecture By: Mr. Malhar Lathkar, Tutorials Point India Private Limited
Рекомендации по теме
Комментарии
Автор

I don't quite understand the second example when the new "myList" object is created within the changme function. I thought when the Python interpreter reaches a variable assignment line, it first checks the local scope to see if a variable of the same name exists. If that were the case, since the myList formal argument would be in the local scope of the changme function, when it reaches the myList = [1, 2, 3, 4] assignment inside the function, one would think it finds the myList variable in the local scope from the formal argument list and changes the value of the object it references (in this case, the myList = [10, 20, 30] object passed to the changme function in its call). Why is this not the case?

isaacdouglas
Автор

thanks i was looking for a concept and i got from here

kirandeepkaur
Автор

that means at 9:00 function ke inside object ko modify krenge to calling environment me bhi object ke value change ho jayega but object ka pura ka pura value hi change kr denge to calling environment me function ke outside wala object hi access hoga . ye kaise? mtlb modify kr skte hi function ke andar pr pura data change nhi kr skte hi? agar change krna ho to kaise karenge? ek ek element ko modify krenge? dimag ka bharosa ho mtlb modification inside the function can be reflected in the callling environment but chnaging the whole objects of mylist cant be reflected.... yahi smjh me nhi aa rha hi koi batao jara

masoom
Автор

At least his english is not the best, but i understand it a lot more, as the python documentation and the people on stackoverflow and other forums hahaha, like <3

Healing_Coding
Автор

this mean there is no passing by reference in python, that affect the variables from the outer environment

bouhannacheabdallah
Автор

Pass by value is not used in Python?!
It is completely wrong. Python passes the list argument by reference, not all types of arguments. List is an mutable object, that's why it is passed by reference. Have you ever tested any other type of argument/object?

babak.basharirad
visit shbcf.ru