title: Using function value as kwargs.get() default
body: <p>I have a factory function for a model with several foreign keys in my unit tests. I would like for that factory function to be variadic, allowing the user to specify the objects to use as foreign keys as keyword arguments, but calling the relevant factory function to spawn a new one for any that are left out.</p>
  
  <p>I originally wrote something like:</p>
  
  <pre><code>def model_factory(i, **kwargs):
      """Create a new Model for testing"""
      test_model_data = {
          'fk1': kwargs.get('fk1', fk1_factory(i)),
          'fk2': kwargs.get('fk2', fk2_factory(i)),
          'fk3': kwargs.get('fk3', fk3_factory(i)),
      }
      return Model.objects.create(**test_model_data)
  </code></pre>
  
  <p>but this calls the fkN_factory() methods even if the keyword is present, causing a lot of side effects that are interfering with my tests. My question is whether or not there is a simpler way to do what I intended here without resulting in lots of needless function calls, rather than what I have now, which is more like:</p>
  
  <pre><code>def model_factory(i, **kwargs):
      """Create a new Model for testing"""
      test_model_data = {
          'fk1': kwargs.get('fk1', None),
          'fk2': kwargs.get('fk2', None),
      }
      if kwargs['f1'] is None:
          kwargs['f1'] = fk1_factory(i)
      if kwargs['f2'] is None:
          kwargs['f2'] = fk2_factory(i)
  </code></pre>