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

    Jul 8, 2017 · class Point: def __init__(self, x, y): _x = x _y = y Your x and y parameters would be stored in variables on the stack and would be discarded when the init method goes out of …

  2. python - Duda con clases. ¿Para que sirve __init__? - Stack …

    Aug 30, 2017 · Estoy empezando en esto de programar y me estoy metiendo en la POO. En python, ¿Porqué en las clases se pone __init__?. Y esto, a lo mejor puede sonar estúpido, …

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

    The characteristic of a type e.g. Germans (hans) are usually defined through the constructor (in python : __init__) at the moment of the instantiation. This is the point where you define a class …

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

    17 In addition to other answers, one point in your question that has not been addressed : Is it necessary to include __init__ as the first function everytime in a class in Python? The answer …

  5. python - Why should we use -> in def __init__ (self, n) -> None ...

    Nov 20, 2020 · Why should we use -> in def __init__(self, n) -> None:? I read the following excerpt from PEP 484, but I am unable to understand what it means. (Note that the return type …

  6. python - Quando devo usar __init__ em funções dentro de classes ...

    Jan 19, 2016 · Pelo livro que estou estudando, em alguns momentos o autor utiliza __init__ como sendo uma primeira função de uma classe. Esta função (e outras) sempre possuem self como …

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

    In fact, it's a good idea to just always inherit from object unless you're writing backwards compat code for very old Python versions. In Python 3, old-style classes are gone and inheritance …

  8. Inheritance and init method in Python - Stack Overflow

    Inheritance and init method in Python Asked 14 years, 8 months ago Modified 2 years, 6 months ago Viewed 197k times

  9. python - Calling a class function inside of __init__ - Stack Overflow

    1 You must declare parse_file like this; def parse_file(self). The "self" parameter is a hidden parameter in most languages, but not in python. You must add it to the definition of all that …

  10. Inheritance and Overriding __init__ in python - Stack Overflow

    Read the answer carefully. It's all about intention. 1) If you want to leave the base class' init logic as is, you don't override init method in your derived class. 2) If you want to extend the init logic …