How is “self” explicitly defined in a method?
Answer / chaitanya
“Self” is a reference variable and an instance attribute that is used instead of the local variable inside the class. The function or the variable of the self like self.x or self.meth() can be used in case the class is not known. There are no variables declared as local. It doesn’t have any syntax and it allow the reference to be passed explicity or call the method for the class that is in use. The use of writebaseclass.methodname(self, <argument list>) shows that the method of _init_() can be extended to the base class methods. This also solves the problem that is syntactic by using the assignment and the local variables. This tells a way to the interpreter the values that are to be used for the instance variables and local variables. The use of explicit self.var solves the problem mentioned above.
| Is This Answer Correct ? | 0 Yes | 0 No |
Describe python usage in web programming?
How to clone or copy a list?
Is set sorted in python?
What do you mean by python literals?
What is the definition of a classifier?
How will you check in a string that all characters are digits?
What is the difference between interpreted and compiled languages?
Is python better than bash?
How do I share global variables across modules?
What is tail recursion?
What are python modules? Name some commonly used built-in modules in python?
Can you modify the maximum depth for a recursive function in Python? If yes how?