I just started programming in Python, and there's something OOP-related that I'm not quite clear on. So in Python, you can create and assign value to a new variable without needing to first declare it. So with that, is there any difference between creating and assigning a new variable for self (eg. self.variable = 5) inside a function (eg. __init__()) vs. creating and assigning a new private member variable? It seems to me like there is no difference at all.
class Foo:
__var_A = 5;
def __init__(self):
self.__var_B = 5;
self.printVars()
def printVars(self):
print(self.__var_A)
print(self.__var_B)
foo = Foo()
__var_Ais going to be "mangled" tofoo.__Foo_var_Aif you are going to access that_Foo__var_A, i.e."_{classname}"prepended.