Quantcast
Viewing latest article 15
Browse Latest Browse All 77

Answer by Oussama L. for What is the purpose of the `self` parameter? Why is it needed?

In the __init__ method, self refers to the newly created object; in other class methods, it refers to the instance whose method was called.

self, as a name, is just a convention, call it as you want ! but when using it, for example to delete the object, you have to use the same name: __del__(var), where var was used in the __init__(var,[...])

You should take a look at cls too, to have the bigger picture. This post could be helpful.


Viewing latest article 15
Browse Latest Browse All 77

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>