Home / Python Class / How to Create a Class in Python In this example we will show how to create a class in Python. Source Code class MyClass: x = 123 def my_function(self): return 'I love Python!' print(MyClass) Output: <class '__main__.MyClass'>