More generally, i was wondering when it is required to use self, not just for methods but for To close debugging questions where op omitted a self parameter for a method and got a typeerror, use typeerror Method () takes 1 positional argument but 2 were given instead In the body of the method and got a nameerror, consider how can. Technically both self and this are used for the same thing They are used to access the variable associated with the current instance
Only difference is, you have to include self explicitly as first parameter to an instance method in python, whereas this is not the case with java Moreover, the name self can be anything. Why is cls sometimes used instead of self as an argument in python classes The reason was an ssl certificate problem To answer this question, you need to have at least 10 reputation on this site (not counting the association bonus) Npm self_signed_cert_in_chain asked 9 years, 10 months ago modified 4 months ago viewed 205k times
Its used when you want to refer to the object's property or field or method inside a class as if you're referring to itself.
OPEN