How to create class objects in Python?



A class object is created using the constructor of the class. This object is then called the instance of the class. Class instantiation uses function notation. 

In the following code we define a class and created an instance of the same class as follows

>>> class Myclass:
pass
>>> x = Myclass()
>>> print x
<__main__.Myclass instance at 0x00000000062F85C8>


Advertisements