2
I saw in other topics some discussions about passing the self
as argument. But it was not very clear to me.
Even though my function has no argument to be started I still need to pass the self
as a first argument?
For example:
class calculadora:
def somar(n1,n2):
return n1+n2
def subtrair(n1,n2):
return n1-n2
c=calculadora()
print(c.somar(5,4))
This class doesn’t need construtor(__init__)
to start no argument but the compiler says :
Typeerror: sum() takes 2 positional Arguments but 3 Were Given
I see no basis for using the self
in the method somar()
, but it is asked.
For this specific case above there is some way to use the method somar()
without passing the self
for him?