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, ∼1696🔥, 0💬
Popular Posts:
How to use the "forward-request" Policy Statement to call the backend service for an Azure API servi...
What Is session_register() in PHP? session_register() is old function that registers global variable...
How to add request URL Template 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 urllib.request.Request object to build more complex HTTP request? The urllib.request....