Open links in new tab
  1. Calling parent class __init__ with multiple inheritance, what's the ...

    Although you can handle the cases where you don't control the source code of A and B by using an adapter class, it is true that you must know how the init's of the parent classes implement super (if at …

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

    Make a directory called 'datetime' and in it make two blank files, the init.py file (with underscores) and datetime.py. Now open an interpreter, import sys, and issue sys.path.insert(0, '/path/to/datetime'), …

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

    Feb 23, 2009 · Why is super() used? Is there a difference between using Base.__init__ and super().__init__? class Base(object): def __init__(self): print "Base created&quot ...

  4. How do I write good/correct package __init__.py files

    My own __init__.py files are empty more often than not. In particular, I never have a from blah import * as part of __init__.py -- if "importing the package" means getting all sort of classes, functions etc …

  5. oop - What do __init__ and self do in Python? - Stack Overflow

    Jul 8, 2017 · init self may make sense for other methods, but what about init? When we call init, we're in the process of creating an object, so how can there already be a self? Python allows us to extend the …

  6. Is __init__.py not required for packages in Python 3.3+

    It's crucial that there are no __init__py files in the google and google/cloud directories so that both directories can be interpreted as namespace packages. In Python 3.3+ any directory on the sys.path …

  7. python - Module imports and __init__.py - Stack Overflow

    Mar 1, 2016 · # foo/Foo.py import foo While this looks convenient since it is a one liner, I am a bit worried that it might be creating circular imports. What I mean is that when the script Foo.py is run it …

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

    I am having trouble understanding the Initialization of classes. What's the point of them and how do we know what to include in them? Does writing in classes require a different type of thinking v...

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

    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 methods that belong to …

  10. How to return a value from __init__ in Python? - Stack Overflow

    Mar 22, 2010 · I have a class with an __init__ function. How can I return an integer value from this function when an object is created? I wrote a program, where __init__ does command line parsing …