title: Default argument value from overridden method (preventing boilerplate)
body: <p>I have a base class <code>Base</code> and two sub classes <code>Foo</code> and <code>Bar</code>. In <code>Base</code> I define a function with an optional argument. This argument is either given or fetched at runtime (not at definition time). The argument is always fetched in the same exact way, which leads to subclasses having a boilerplate line of code (sure it's one line, but it's just an example). Normally this would look like this:</p>
  
  <pre><code>class Base(object):
      def greet(self, name=None):
          pass
  
  class Foo(Base):
      def greet(self, name=None):
          name = name or get_name_at_runtime()
          print('Hello {name} this is Foo.'.format(name=name))
  
  class Bar(Base):
      def greet(self, name=None):
          name = name or get_name_at_runtime()
          print('Hello {name} this is Bar.'.format(name=name))
  </code></pre>
  
  <p>Now I came up with a hack that solves this problem, but I don't find this to be a solid solution. The solution involves defining a private method that wraps the overridden method and supplies it with the correct value. Both methods are switched in the <code>__init__</code> so calling/overriding the method feels 'normal':</p>
  
  <pre><code>class Base(object):
      def __init__(self):
          self.greet, self.__greet = self.__greet, self.greet
  
      def greet(self, name):
          pass
  
      def __greet(self, name=None):
          self.__greet(name or get_name_at_runtime())
  
  class Foo(Base):
      def greet(self, name):
          print('Hello {name} this is Foo.'.format(name=name))
  
  class Bar(Base):
      def greet(self, name):
          print('Hello {name} this is Bar.'.format(name=name))
  </code></pre>
  
  <p>The 'solution' I came up with poses the problem that it's not clear that name is optional since it looks like it doesn't have a default value.</p>
  
  <p>In some cases <code>Base</code> is an abstract base class and in some cases it's not, so I'm looking for a solution that supports both.</p>