0
How do i PRINT any method i want from a class ?? Whenever i try it just gives me it's location in memory i believe.(
class Employee: def __init__(self, first, last): self.first = first self.last = last self.email = f"{self.first}.{self.last}@email.com" def fullname(self): return self.first, self.last def __str__(self): return f"{self.first},{self.last}" eric = Employee("eric", "larson") print(eric.fullname) print(eric.email)
4 Réponses
+ 5
print(eric.fullname())
+ 2
Intermediate Depression When you call a function with parentheses, you are telling the interpreter that you want to execute the code inside that function.
When you use the function name without parentheses, you are referring to the function itself as an object.
This can be useful, for example, if you want to pass the function as an argument to another function or store it in a variable.
if you call a function without parentheses, you won't execute the code inside that function. You're simply referring to the function object, which can be used later for calling.
0
Alexey Kopyshev TYSM, i am very amazed at how simple the answer is wow.....can you please explain what is the difference? (Between calling it like a function and calling it normally how i did in my code!)
0
Alexey Kopyshev Again thank you so much you have no idea how much you have helped me, i really appreciate your help.