What is the function of “self”?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is python coverage?

444


How are the functions help() and dir() different?

457


How can you sort a list?

591


Which is best framework for python?

441


Difference between append vs. Extend list methods in python

484






What is different between class and object?

451


What is the syntax for dictionary comprehension in python?

483


How many rows can pandas handle?

471


What is thread join in python?

447


Explain the five benefits of using python?

435


Is empty python dataframe?

434


Tell me what are generators in python?

454


What is a lambda function?

437


What is the difference between raw_input() and input() in python?

471


How do I run a script in python shell?

467