title: Python using derived class's method in parent class?
body: <p>Can I force a parent class to call a derived class's version of a function?</p>
  
  <pre><code>class Base(object):
      attr1 = ''
      attr2 = ''
  
      def virtual(self):
          pass               # doesn't do anything in the parent class
  
      def func(self):
          print "%s, %s" % (self.attr1, self.attr2)
          self.virtual()
  </code></pre>
  
  <p>and a class that derives from it</p>
  
  <pre><code>class Derived(Base):
      attr1 = 'I am in class Derived'
      attr2 = 'blah blah'
  
      def virtual(self):
          # do stuff...
          # do stuff...
  </code></pre>
  
  <p>Clearing up vagueness:</p>
  
  <pre><code>d = Derived()
  d.func()         # calls self.virtual() which is Base::virtual(), 
                   #  and I need it to be Derived::virtual()
  </code></pre>