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, 1257🔥, 0💬
Popular Posts:
How to install .NET Framework in Visual Studio Community 2017? I have the Visual Studio Installer in...
How To Read a File in Binary Mode in PHP? If you have a file that stores binary data, like an execut...
How to read Atom validation errors at w3.org? If your Atom feed has errors, the Atom validator at w3...
How to register and get an application ID from Azure AD? The first step to use Azure AD is to regist...
How to run CMD Commands in Dockerfile to change Windows Docker images? When building a new Windows i...