Home / Python Class / How to Use Class to Create Objects in Python In this example we will show how to use the class to create objects in Python. Source Code class MyClass: x = 123 def my_function(self): return 'I love Python!' obj_1 = MyClass() print(obj_1.x) Output: 123