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, ∼2321🔥, 0💬
Popular Posts:
How to make application release build with Visual Studio 2017? If you want to make a final release b...
Where to find tutorials on RSS specifications? I want to learn it to describe my API services. Here ...
What is EPUB 3.0 Metadata "dc:description" Element? EPUB 3.0 Metadata "dc:description" is an optiona...
How to use .NET CLR Types in Azure API Policy? By default, Azure imports many basic .NET CLR (Common...
How To Pad an Array with the Same Value Multiple Times in PHP? If you want to add the same value mul...