title: How to use python superclass and inheritance (turtle graphics example)?
body: <p>I've been playing around with turtle graphics, trying to better understand objects and I've encountered a little issue. I've learned about the super() function and wanted to use it:</p>
  
  <pre><code>from turtle import Turtle, _Screen, Screen    
  
  class turtle(Turtle):
      def __init__(self):
          super().__init__(shape="circle")            
  
  wn = Screen()
  tortoise = turtle()
  </code></pre>
  
  <p>So if I do this, everything works like charm. I get a screen and I can use any Turtle method on my turtle class.</p>
  
  <pre><code>from turtle import Turtle, _Screen, Screen
  
  class window(_Screen):
      def __init__(self):
          super().__init__()
          self.setup(500,500)
          self.screensize(1000,1000)
          self.title("Title")
          self.bgcolor("black")
  
  wn = window()
  </code></pre>
  
  <p>This will also work great, I get what I ask: black window of 1000x1000 in a 500x500 box with slide bars. No problem. But, if I want to combine these:</p>
  
  <pre><code>from turtle import Turtle, _Screen, Screen
  
  class window(_Screen):
      def __init__(self):
          super().__init__()
          self.setup(500,500)
          self.screensize(1000,1000)
          self.title("Title")
          self.bgcolor("black")
  
  class turtle(Turtle):
      def __init__(self):
          super().__init__(shape="circle")
  
  wn = window()
  tortoise = turtle()
  </code></pre>
  
  <p>It will display the screen, but I will get an error from the turtle:</p>
  
  <blockquote>
    <p>AttributeError: '_Screen' object has no attribute '_mode'</p>
  </blockquote>
  
  <p>I have been looking through the turtle module and found that the Screen() function does this:</p>
  
  <pre><code>def Screen():
      """Return the singleton screen object.
      If none exists at the moment, create a new one and return it,
      else return the existing one."""
      if Turtle._screen is None:
          Turtle._screen = _Screen()
      return Turtle._screen
  </code></pre>
  
  <p>So I modified the window class to include this:</p>
  
  <pre><code>from turtle import Turtle, _Screen, Screen
  
  class window(_Screen):
      def __init__(self):
          Turtle._screen = Screen()
          super().__init__()
          #self.setup(500,500)
          #self.screensize(1000,1000)
          #self.title("Title")
          #self.bgcolor("black")
  
  class turtle(Turtle):
      def __init__(self):
          super().__init__(shape="circle")
  
  wn = window()
  tortoise = turtle()
  </code></pre>
  
  <p>It works like this, I will get a white window, with a round turtle. But if I uncomment the <strong><em>setup</em></strong>, the <strong><em>screensize</em></strong> or the <strong><em>bgcolor</em></strong> part, I will get an error:</p>
  
  <blockquote>
    <p>AttributeError: 'window' object has no attribute '_tracing' </p>
  </blockquote>
  
  <p>or</p>
  
  <blockquote>
    <p>AttributeError: 'window' object has no attribute 'cv'</p>
  </blockquote>
  
  <p>So I would again have to declare some parameters before the <strong><em>__init__</em></strong> in the <strong><em>window</em></strong> class, to make it work. It seems there is something I'm missing. Why does the turtle inherit everything and works great, but the <strong><em>_Screen</em></strong> is not initializing with all it's necessary parameters?</p>