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 |
What does quit () do in python?
We know python is all the rage these days. But to be truly accepting of a great technology, you must know its pitfalls as well. Would you like to talk about this?
Why do we say “a b c = 1000 2000 3000” is an invalid statement in python?
What is an elif in python?
Can python be used for web client and web server side programming? And which one is best suited to python?
What is python and why python?
What is deep copy in python?
How will you get all the keys from the dictionary?
What are the key features of using python?
Does python support inheritance?
How would you implement inheritance in python?
What are the differences in list and tuple?