If I have a function that returns a value or True and False, but does not have a variable to receive, can this cause some problem in the code operation?
Example:
def Retorna():
return False
def Retorna2():
return 100
Retorna()
Retorna2()
If I have a function that returns a value or True and False, but does not have a variable to receive, can this cause some problem in the code operation?
Example:
def Retorna():
return False
def Retorna2():
return 100
Retorna()
Retorna2()
No problem at all.
Although it is not a typical Python language design, where it is common to have functions without a return value, it is possible for a function to always return the object it acted on - use of this returned value is optional.
In Javascript and in some Python libraries it is common to always return the object on which the function acted - that way you can chain other direct calls into the return value. But if you do not have other calls, nothing happens.
There is not even an extra memory expense - if there is no variable to store a return value: as soon as it is returned, as it has no reference to it, it is destroyed, and its memory released. >