Sunday 16 August 2015

Purpose of self in Python

from selenium import webdriver
#
Class MyClass:
    def function(self):
        self.driver = webdriver.Firefox()

What is the purpose of SELF here:
"
self is an object reference to the object itself, therefore, they are same. Python methods are not called in the context of the object itself. self in Python may be used to deal with custom object models or something.
"

"
The self variable refers to the object itself.
"

Source:
http://stackoverflow.com/questions/2709821/what-is-the-purpose-of-self-in-python
 

No comments:

Post a Comment