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, ∼2682🔥, 0💬
Popular Posts:
How to use the "send-one-way-request" Policy statement to call an extra web service for an Azure API...
How to use the JSON to XML Conversion Tool at utilities-online.info? If you want to try the JSON to ...
How to add request query string Parameters to my Azure API operation to make it more user friendly? ...
Where to get the detailed description of the JSON.stringify() Function in JavaScript? Here is the de...
How to use the Atom Online Validator at w3.org? w3.org feed validation service is provided at http:/...