Problem and Solutions
How other members of a python class are bound to the instance? [duplicate] in python ?
By M.K. Verma · 3 May 2022
![How other members of a python class are bound to the instance? [duplicate] in python ?](/_next/image?url=https%3A%2F%2Fserveapi.trimwebsolutions.com%2Fuploads%2Flegacy%2Fblog%2F16515742861651574286.jpg&w=3840&q=65)
because it's declared as a class variable, not an instance variable.
Class variable: Once copy of variable is shared between all instances.
Instance variable: Each instance has its own value and not shared between different instances of same class.
the following code will give you false.
class a:
def __init__(self):
self.name = 'Adam'
self.e = [1,2,3]
b = a()
c = a()
if b.e is c.e:
print('they are same')
else:
print("not the same")
output
"not the same"