For example I have class
Class Cls:
var 1
var 2
def func(self):
--- do some statement
Now, I can simply import class and create object
import Cls
clsObj = Cls()
Here, Cls is class and clsObj is instance of class. Is there any way that I distinguish between them.
Thank you
Yes, just use the builtin type() which gives the type of a particular object. type(clsObj) will give Instance as the answer. You can also check with
isinstanceisinstance(clsObj,Cls)will returnTruewhereasisinstance(Cls,Cls)will returnFalse