Python supports object-oriented programming with classes, instances, the self parameter, __init__ constructors, and inheritance. Page Object Model frameworks are built on these.
class LoginPage: def __init__(self, driver): self.driver = driver defines a class; self refers to the instance and must be the first parameter of instance methods. __init__ initializes attributes. Inheritance (class LoginPage(BasePage)) reuses/extends a parent, and super().__init__() calls the parent constructor. Methods can be overridden. Testers use OOP for Page Objects (each page a class with locators + actions), base classes for shared setup, and mixins for reusable behavior. Class vs instance attributes matter: class attributes are shared across instances.
A Page Object: class LoginPage(BasePage): def login(self, user, pw): self.type(self.USER, user); self.type(self.PASS, pw); self.click(self.SUBMIT) — encapsulating the login page's locators and actions in one class.
A candidate defines a class attribute results = [] and finds every Page Object instance shares the same list. Why?