code: def expand(tmpl, *args, **kwargs):
      
      replacer = functools.partial(_expand_variable_match, list(args), kwargs)
      return _VARIABLE_RE.sub(replacer, tmpl)
docs: Expand a path template with the given variables.
  
      ..code-block:: python
  
          >>> expand('users/*/messages/*', 'me', '123')
          users/me/messages/123
          >>> expand('/v1/{name=shelves/*/books/*}', name='shelves/1/books/3')
          /v1/shelves/1/books/3
  
      Args:
          tmpl (str): The path template.
          args: The positional variables for the path.
          kwargs: The named variables for the path.
  
      Returns:
          str: The expanded path
  
      Raises:
          ValueError: If a positional or named variable is required by the
              template but not specified or if an unexpected template expression
              is encountered.