title: Force specific function signatures
body: <p>I just caught myself writing code like this:</p>
  
  <pre><code>def register(self, *,  # * enforces keyword-only parameters
               key_value_container:dict=None,    # legal parameter set #1
               key:str=None, value=None):        # legal parameter set #2
  
      # enforce one of the parameter sets
      if not ((key_value_container is not None and 
               key is None and value is None) or
              (key is not None and value is not None and 
               key_value_container is None)):
          raise TypeError('provide (key_value_container) or (key/value')
  
      # handle each legal parameter setf
      if key_value_container is not None:
          for _k, _s in key_value_container.items():
              self.register(_k, _s)
      else:
          do_something_with(key, value)
  </code></pre>
  
  <p>My goal was to have two signatures of the method <code>register()</code>: it should take a <code>key</code> and a <code>value</code> or some container with a number of keys and values e.g. a <code>dict</code>.</p>
  
  <p>The <code>*</code> in the argument at least forces me to provide named arguments but there is no need to provide <em>a given number of arguments</em> or even <em>a given set of arguments</em>.</p>
  
  <p>Of course I can (should) provide two methods with different names and signatures instead of one.</p>
  
  <p>But in case I want (have) to provide one method/function with more than one parameter semantics - what's the best way to make this visible and enforce it?</p>
  
  <p>In detail:</p>
  
  <ul>
  <li>is it possible to make clear in <em>auto-completion</em> and <em>documentation</em> which are the legal parameter combinations?</li>
  <li>how do I check (with as little boilerplate code as possible) whether one combination has been provided?</li>
  </ul>