code: def genrepl(scope):
      
  
      def repl(match):
          """Internal replacement function."""
  
          name = match.group('name')
  
          value = lookup(name, scope=scope)
  
          result = name.replace('.', '_')
          scope[result] = value
  
          return result
  
      return repl
docs: Replacement function with specific scope.