is instance in python code example
Example 1: isinstance python
isinstance(object, classinfo)
# if classinfo is a tuple of type objects (or recursively, other such tuples), return True
# if object is an instance of any of the types. If classinfo is not a type or tuple of types
# and such tuples, a TypeError exception is raised.
Example 2: is instance string python
isinstance(x, int)
isinstance(s, str)
Example 3: instance method in python
# Instance Method Example in Python
class Student:
def __init__(self, a, b):
self.a = a
self.b = b
def avg(self):
return (self.a + self.b) / 2
s1 = Student(10, 20)
print( s1.avg() )
Example 4: python instance Object
x.counter = 1
while x.counter < 10:
x.counter = x.counter * 2
print(x.counter)
del x.counter
#https://docs.python.org/3.8/tutorial/classes.html#class-objects