title: Basic Polymorphism Confusion in Python
body: <p>I'm reading Python 3 Object-Oriented Programming and am a bit confused by one of the examples.  It's ch. 3, p. 78:</p>
  
  <pre><code>class AudioFile:
      def __init__(self, filename):
          if not filename.endswith(self.ext):
              raise Exception("Invalid file format")
          self.filename = filename
  
  class MP3File(AudioFile):
      ext = "mp3"
      def play(self):
          print("playing {} as mp3".format(self.filename))
  </code></pre>
  
  <p>So <code>MP3File</code> inherits from <code>AudioFile</code>.  How is <code>AudioFile</code>, the superclass, able to access <code>self.ext</code>?  For instance, Java has abstract classes, so there's no guarantee that AudioFile can necessarily be instantiated / has an <code>ext</code> field.  More to the point, I thought that subclasses inherit all info from superclasses but that there was no flow of information in the other direction. </p>
  
  <p>Seems I'm wrong...</p>
  
  <p>Any clarification would be great,</p>
  
  <p>bclayman</p>