Am starting to learn python's classes and objects! I read alone from an ebook. The book has the following example:
class Person:
def sayHi(self):
print('Hello, how are you?')
p = Person()
p.sayHi()
# or simplier
Person().sayHi()
I can totally understand the following:
def sayHi():
print('Hello, how are you?')
sayHi()
However, I have a difficulty understanding the 1st example... Why do I need to use this 'self'? Does the use of 'self' tells python that I can use/call the function sayHi() by calling the class? Other-words, does the 'self' give the right to class Person to react as if it was a function... like passing the rights to the above level?
P.S. Sorry but I am noob in programming and also English is not my mother-lang.. Thanks in advance.