I would like to understand better why using __init__
by comparing these two code, I even understood that __init__
will always be started with the instantiated object, but should I always use it?
With __init__:
class Cliente():
def __init__(self,saldo,nome):
self.__saldo = nome
self.__nome = saldo
def getsaldo(self):
return self.__saldo
def setsaldo(self,saldo):
self.__saldo = saldo
def setnome(self,nome):
self.__nome = nome
def getnome (self):
return self.__nome
No __init__:
class Cliente():
__saldo = 0
__nome = None
def getsaldo(self):
return self.__saldo
def setsaldo(self,saldo):
self.__saldo = saldo
def setnome(self,nome):
self.__nome = nome
def getnome (self):
return self.__nome