What does self mean?

Mondo Education Updated on 2024-02-18

Self as an English word, mainlythemselvesThe meaning is the same as i, my and meSelf-pronouns;In addition to the commonly used meanings, self has the following types of meanings:

However, self is not only used as a stand-alone word in English, but also as suchSuffixand other pronoun pronouns to be combinedSo-and-so himselfmeaning, such as:myselfRepresentationMyselfyourselfRepresentationYourselfhimselfRepresentationHimselfherselfRepresentationherselfthemselvesRepresentationthemselvesorthemselves。By way of comparison, since self can be used as a suffix, can it also be used as a prefix? The answer is yes.

The words prefixed with self are self-confidence, self-help and self-awareness, etc., which can be said to be quite rich, and those who are interested can learn about it by themselves, and there will be no more expansion here, otherwise this article will be **English dictionary.

The word self should also be known to people who have programming experience or work in programming to be a keyword in Python. Specifically, self is used as a keyword in Python programming to be used primarily for surface line object programming, i.e., when declaring member functions that define classes, as shown in the following examples:

In Python syntax, the member function of the class body must have self as the argument to the function, and it must be the first argument. If you don't use self as a parameter, the editor will get an error:

Actually, it's easy to understand that Python has given up the concept of pointers, so there's no way to access class variables through this pointer like in C C++ and J**A, only through this self, and the self in Python is actually a reference to the class object itself:

What if the class member function doesn't declare self as the first argument?

As shown above, the python interpreter will fail to executeThe first argument of the class member function is used as self as a fixed oneSo, when declaring the definition of a Python class, be sure to take self as the first argument to the member function. At this point, you should have reached the point where calling a class member method in Python programming does not pass any arguments, and does not mean that the member method is an empty list of arguments in the declaration definition.

Related Pages