About 27,300,000 results
Open links in new tab
  1. oop - What do __init__ and self do in Python? - Stack Overflow

    Jul 8, 2017 · In this case, there are some benefits to allowing this: 1) Methods are just functions that happen defined in a class, and need to be callable either as bound methods with implicit self passing …

  2. What is the purpose of the `self` parameter? Why is it needed?

    For a language-agnostic consideration of the design decision, see What is the advantage of having this/self pointer mandatory explicit?. To close debugging questions where OP omitted a self …

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

    Oct 18, 2016 · Are you supposed to use self when referencing a member function in Python (within the same module)? More generally, I was wondering when it is required to use self, not just for methods …

  4. What difference does it make to use "self" to define a member in a ...

    A.x is a class variable. B 's self.x is an instance variable. i.e. A 's x is shared between instances. It would be easier to demonstrate the difference with something that can be modified like a list:

  5. oop - Why do you need explicitly have the "self" argument in a Python ...

    By making the self reference explicit, you're free to refer to any object by that self reference. Also, such a way of playing with classes at runtime is harder to do in the more static languages - not that's it's …

  6. When to use self, &self, &mut self in methods? - Stack Overflow

    Nov 24, 2019 · Self is an alias for the type that the impl block is for. The rules of ownership and borrowing apply to self as they apply to any other parameter (see e.g. this answer). Examples of …

  7. oop - Understanding "self" in Python - Stack Overflow

    Sep 15, 2012 · in python to call inner class method you should write self. before method name, self. means that search class for this method but you don't use self when you call say_hi() in …

  8. Difference between 'cls' and 'self' in Python classes?

    Why is cls sometimes used instead of self as an argument in Python classes? For example: class Person: def __init__(self, firstname, lastname): self.firstname = firstname self.

  9. What does "\\.self" actually do in Swift/SwiftUI? - Stack Overflow

    Jul 4, 2020 · I think it is setting the id for each list item as each item in the numbers array? Correct me if wrong - but is each id being set as whatever Int is in each entry of the numbers array? If so, then …

  10. ios - What is "self" used for in Swift? - Stack Overflow

    Nov 10, 2014 · When self is accessed in a type method (static func or class func), it refers to the actual type (rather than an instance). When self is used this way, it actually returns what in Swift is called a …