What is the function of “self”?



What is the function of “self”?..

Answer / chaitanya

“Self” is a variable that represent the instance of the object to itself. In most of the object oriented programming language, this is passed as to the methods as a hidden parameters that is defined by an object. But, in python it is declare it and pass it explicitly. It is the first argument that gets created in the instance of the class A and the parameters to the methods are passed automatically. It refers to separate instance of the variable for individual objects. This is the first argument that is used in the class instance and the “self” method is defined explicitly to all the methods that are used and present. The variables are referred as “self.xxx”.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

Why Should We Use File Operation?

1 Answers  


Is python interpreted or compiled?

1 Answers  


What are class or static variables in python programming?

1 Answers  


How to iterate through two lists in parallel?

1 Answers  


Do python arrays start at 0 or 1?

1 Answers  


Tell me how does python handle the memory management?

1 Answers  


What is the difference between old style and new style classes in python?

1 Answers  


What do you mean by instance?

1 Answers  


What is decorator in python?

1 Answers  


What are methods in python?

1 Answers  


How to comment multiple lines in python?

1 Answers  


What is asynchronous python?

1 Answers  


Categories