Quantcast
Channel: What is the purpose of the `self` parameter? Why is it needed? - Stack Overflow
Viewing all articles
Browse latest Browse all 77

Answer by dan-klasson for What is the purpose of the word 'self', in Python?

$
0
0

It’s there to follow the Python zen “explicit is better than implicit”. It’s indeed a reference to your class object. In Java and PHP, for example, it's called this.

If user_type_name is a field on your model you access it by self.user_type_name.


Viewing all articles
Browse latest Browse all 77

Trending Articles



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