Tools, FAQ, Tutorials:
Where Are Instance Properties Stored
Where Are Instance Properties Stored?
✍: FYIcenter.com
Instance properties are stored in a built-in property called "__dict__" in each instance object.
The "__dict__" property is inherited from the base class "object" and managed by the Python engine.
If you ever forget what instance properties are associated with a specific instance object, you can always look at the content of the built-in property "__dict__". For example:
>>> class user():
... nextID = 1
... def __init__(self,name="Joe",age=25):
... self.id = user.nextID
... self.name = name
... self.age = age
... user.nextID = user.nextID + 1
...
>>> x = user()
>>> x.remark = "Smart guy!"
>>> x.__dict__
{'id': 6, 'name': 'Joe', 'age': 25, 'remark': 'Smart guy!'}
⇒ Access Class Properties through Instance Name
⇐ Manage and Use Instance Properties
2022-09-24, ∼1513🔥, 0💬
Popular Posts:
Where can I download the EPUB 2.0 sample book "The Problems of Philosophy" by Lewis Theme? You can f...
How To Copy Array Values to a List of Variables in PHP? If you want copy all values of an array to a...
How to login to Azure API Management Publisher Dashboard? If you have given access permission to an ...
How to use the "send-one-way-request" Policy statement to call an extra web service for an Azure API...
How to reinstall npm with a node version manager? I am getting permission errors with the current ve...