def positional(max_positional_arguments):
  """A decorator to declare that only the first N arguments my be positional.

  This decorator makes it easy to support Python 3 style key-word only
  parameters.  For example, in Python 3 it is possible to write:

    def fn(pos1, *, kwonly1=None, kwonly1=None):
      ...

  All named parameters after * must be a keyword:

    fn(10, 'kw1', 'kw2')  # Raises exception.
    fn(10, kwonly1='kw1')  # Ok.

  Borrowed from ProtoRPC:

  http://code.google.com/p/google-protorpc/source/browse/python/protorpc/util.py#50

  Args:
    max_positional_arguments: Maximum number of positional arguments.  All
      parameters after the this index must be keyword only.

  Returns:
    A decorator that prevents using arguments after max_positional_args from
    being used as positional parameters.

  Raises:
    TypeError if a key-word only argument is provided as a positional parameter.
  """
  def positional_decorator(callable):
    def positional_wrapper(*args, **kwargs):
      if len(args) > max_positional_arguments:
        raise TypeError('Call to %s accepts only %d parameters' %
                        (callable.__name__, max_positional_arguments))
      return callable(*args, **kwargs)
    positional_wrapper.__name__ = callable.__name__
    return positional_wrapper
  return positional_decorator