Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>'super' part here is only to properly call constructor of base class (the class you are inheriting from.) Let's consider following example:</p> <pre><code>class Device(): # class representing some drawing device ... def fill(self, color) ... # actual code for draw on this device screen = Device() WHITE_COLOR = (255, 255, 255) class Window(object): def __init__(self, width, height): self.width = width self.height = height def area(self): return self.width * self.height class ColoredWindow(Window): def __init__(width, height, color): super(ColoredWindow, self).__init__(width, height) self.color = color def fill(self): screen.fill(self.width, self.height, self.color) my_window = ColoredWindow(640, 480, WHITE_COLOR) my_window.fill() </code></pre> <p>The first class here, <code>Window</code>, is a generic window that has <code>width</code> and <code>height</code> attributes that are passed in constructor. <code>ColoredWindow</code> is a subscass of <code>Window</code>, it has additional attribute <code>color</code>. When <code>ColoredWindow</code> is constructed, it needs somehow pass <code>width</code> and <code>height</code> parameters to its baseclass <code>Window</code>.</p> <p>This is exactly what construction <code>super(ColoredWindow, self).__init__(width, height)</code> is for. The first part, <code>super(ColoredWindow, self)</code>, returns a reference to baseclass (<code>Window</code> in our case), and second part, <code>__init__(width, height)</code>, just calls its constructor with right parameters. </p> <p>In your example <code>master</code> is not called, it's just parameter to <code>__init__</code> method of <code>Application</code> class.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload