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

    Jul 8, 2017 · Python doesn't force you on using " self ". You can give it any name you want. But remember the first argument in a method definition is a reference to the object. Python adds …

  2. Why do we use __init__ in Python classes? - Stack Overflow

    5 It seems like you need to use __init__ in Python if you want to correctly initialize mutable attributes of your instances. See the following example:

  3. class - __new__ and __init__ in Python - Stack Overflow

    For reference, check out the requirements for __new__ in the Python Language Reference. Edit: ok, here's an example of potentially useful use of __new__. The class Eel keeps track of how …

  4. python - What is __init__.py for? - Stack Overflow

    Here's the documentation. Python defines two types of packages, regular packages and namespace packages. Regular packages are traditional packages as they existed in Python …

  5. Is it necessary to include __init__ as the first function every time in ...

    80 In Python, I want to know if it is necessary to include __init__ as the first method while creating a class, as in the example below:

  6. python - Why is __init__ () always called after __new__ ()? - Stack ...

    In Python, this corresponds to the class' __init__ method. Python's __new__ is nothing more and nothing less than similar per-class customisation of the "allocate a new instance" part. This of …

  7. Understanding Python super() with __init__() methods

    Feb 23, 2009 · Just a heads up... with Python 2.7, and I believe ever since super() was introduced in version 2.2, you can only call super() if one of the parents inherit from a class that eventually …

  8. python - Calling parent class __init__ with multiple inheritance, …

    Because of the way diamond inheritance works in python, classes whose base class is object should not call super().__init__(). As you've noticed, doing so would break multiple inheritance …

  9. Inheritance and init method in Python - Stack Overflow

    In the first situation, Num2 is extending the class Num and since you are not redefining the special method named __init__() in Num2, it gets inherited from Num. When a class defines an …

  10. oop - What does 'super' do in Python? - Stack Overflow

    Nov 3, 2015 · Python linearizes a complicated inheritance tree via the C3 linearization algorithm to create a Method Resolution Order (MRO). We want methods to be looked up in that order. For …