The "self" as a reference to an instance of an object is still confounding. Also "self" is a stand in that is arbitrary and can be assigned any name within the special method __init__. "self" is used to refer to a particular instance of an object so that methods within the defining class can access the paticular instance attributes of the object to perform whatever behavior that is determined by the class. The nuances are strange and the documentation available online is positively ungrammatical and confusing. The tutorials are really poorly written with lots of errors. Luckily to aide this situation there are resources that are not free though are written rather better like realpython.com. I am writing out what I have recently learned to help retain the concepts at hand. Objects are useful for code encapsulation and better organized code. This reminds me of a book I read about orthogonality which is trying to make code that is modular and piece together in parts versus being one blob in one file. Object oriented code allows this by breaking code into units that can be reused over again with little code rewriting. The task of writing code is quite onerous in some respects when you explore deeper in nontrivial code bases and see the structure and architecture of mature open source projects. All in all it is all organized quite well and makes for performant code like the code for dataclasses or pathlib.

Comments

Popular posts from this blog