What is the purpose of the self
word in Python? I understand it refers to the specific object created from that class, but I can't see why it explicitly needs to be added to every function as a parameter. To illustrate, in Ruby I can do this:
class myClass
def myFunc(name)
@name = name
end
end
Which I understand, quite easily. However in Python I need to include self
:
class myClass:
def myFunc(self, name):
self.name = name
Can anyone talk me through this? It is not something I've come across in my (admittedly limited) experience.