code: def expand(template, variables=None):
      
      if variables is None:
          variables = {}
      return patterns.sub(functools.partial(_replace, variables), template)
docs: Expand a URL template string using the passed variables