Introduction to Python classes and its features
Python class methods — staticmethod, classmethod, property
Hello people and welcome to another article related to Python and its object oriented features. In this article we are going to build a simple class that we started in our previous article and talk about most used feature when building such classes. Without further ado let’s get started.
In the previous article, we’ve made a simple material class as shown below. We have encountered couple of core concepts like init, str and repr dunder methods. In this article we will build on top of it, thus expanding our knowledge about python classes and all of its features. Keep in mind that some of the previous code we’ve written won’t be shown/rewritten for brevity.
Let’s start with building a simple method within the class that will interact will class instances.
def pprint(self):
print(f'Printing information for object {id(self)}')
print(f'{self.title} has {self.color} color')