+ 1
What's the difference between a and b in these two python classes?
What is the difference between these? class A(): def __init__(self, a, b): self.a = a self.b = b VS class A(): a = 1 b = 1 def __init__(self, a, b): self.a = a self.b = b
2 Respuestas
+ 1
In the first case, self.a and self.b are instance variables.
In the second case, a and b are class variables, and self.a and self.b are instance variable.
There is a huge difference between instance variable and class variable.
0
Nothing different we just have same extra properties in above one along with constructor