About 13,400,000 results
Open links in new tab
  1. self in Python class - GeeksforGeeks

    Feb 26, 2025 · In Python, self is used as the first parameter in instance methods to refer to the current object. It allows methods within the class to access and modify the object's attributes, …

  2. python - What is the purpose of the `self` parameter? Why is it …

    def func(self, name): self.name = name. I know that self refers to the specific instance of MyClass. But why must func explicitly include self as a parameter? Why do we need to use self in the …

  3. Python Self - W3Schools

    The self parameter is a reference to the current instance of the class, and is used to access variables that belongs to the class. It does not have to be named self , you can call it whatever …

  4. Understanding Python self Variable with Examples - AskPython

    Sep 5, 2019 · Python self variable is used to bind the instance of the class to the instance method. We have to explicitly declare it as the first method argument to access the instance …

  5. self in Python, Demystified - Programiz

    What is self in Python? In object-oriented programming, whenever we define methods for a class, we use self as the first parameter in each case. Let's look at the definition of a class called Cat.

  6. What Is 'self' in Python? A Complete Guide (with Examples)

    In Python, self refers to the class object itself. With self, you are able to access the attributes and methods of the class. For instance, this Fruit class assigns a custom name and color to itself …

  7. Demystifying the self Parameter: A Complete Guide to Using self

    Jul 11, 2023 · The self parameter is a special parameter that is passed to methods in Python classes. It binds the instance of the class to the method, allowing the method to access and …

  8. Understanding "self" in Python Classes: A Complete Guide

    2 days ago · The Historical Context of "self" Python‘s explicit "self" parameter wasn‘t a random design choice. Guido van Rossum, Python‘s creator, made this decision deliberately. ... it‘s …

  9. What is the use of Self in Python? - Edureka

    Dec 5, 2024 · In Python, self is used every time you define it because it helps the method know which object you are actually dealing with. When you call a method on an instance of a class, …

  10. When do you use 'self' in Python? - Stack Overflow

    Oct 18, 2016 · Use self to refer to instance variables and methods from other instance methods. Also put self as the first parameter in the definition of instance methods. An example: