Tools, FAQ, Tutorials:
Function Parameters Assigned with Object References
Is it true that all function parameters are assigned with object references in Python?
✍: FYIcenter.com
Yes, all function parameters are assigned with object references in Python.
You modify referenced data objects to share data with the calling statement.
Here is a good example of modifying the data object referenced by the parameter:
IndentationError: unexpected indent >>> def load(name,age,user): ... profile = {"name":name,"age":age} ... user["profile"] = profile ... >>> guest = {} >>> load("Joe",25,guest) >>> guest {'profile': {'name': 'Joe', 'age': 25}}
Note that both variables "guest" and "user" are referring to the same data object.
⇐ Variable Scope in Function Definition Statements
2018-02-08, 1162👍, 0💬
Popular Posts:
How to write a policy to set and get custom variables? Here is a policy that sets and gets custom va...
What properties and functions are supported on requests.models.Response objects? "requests" module s...
How To Loop through an Array without Using "foreach" in PHP? PHP offers the following functions to a...
Where to find tutorials on the 2017 version of API Management Services at Azure Portal? Here is a li...
How to run PowerShell Commands in Dockerfile to change Windows Docker images? When building a new Wi...