How?
To begin with, the correct answer is that python's parameter passing mechanism is call by assignment. It is also referred to as call by object-reference or call by sharing, all of which mean the same thing. In Python, when a function is called, the argument is passed as a reference to the object.
To help understand this, consider that data types like int or str are immutable objects, so even if you try to change their values within a function, the original object will not be affected. On the other hand, for mutable objects like list or set, if you try to modify them inside a function, the original object will also be changed. In other words, it can be understood as a mix of call by value and call by reference.
Object Reference Passing
For immutable objects → call by value
For mutable objects → call by reference
'Basics (종료) > For EN' 카테고리의 다른 글
[IntelliJ] When Ctrl + Shift + F10 doesn't work (0) | 2024.12.09 |
---|---|
[DS] Stack, Queue, Deque (0) | 2024.11.25 |
[Python] Time Complexity: No String Concatenation! (0) | 2024.11.18 |
[Python] Linked List: What is the Node include? (4) | 2024.11.11 |
[Python] Arrays: Is the starting index 0 or 1? (3) | 2024.11.04 |