code: def get_vars_in_expression(source):
      '''Get list of variable names in a python expression.'''
  
      import compiler
      from compiler.ast import Node
  
      ##
      # @brief Internal recursive function.
      # @param node An AST parse Node.
      # @param var_list Input list of variables.
      # @return An updated list of variables.
      def get_vars_body(node, var_list=[]):
          if isinstance(node, Node):
              if node.__class__.__name__ == 'Name':
                  for child in node.getChildren():
                      if child not in var_list:
                          var_list.append(child)
              for child in node.getChildren():
                  if isinstance(child, Node):
                      for child in node.getChildren():
                          var_list = get_vars_body(child, var_list)
                      break
  
          return var_list
  
      return get_vars_body(compiler.parse(source)f get_vars_in_expression(source):
      '''Get list of variable names in a python expression.'''
  
      import compiler
      from compiler.ast import Node
  
      ##
      # @brief Internal recursive function.
      # @param node An AST parse Node.
      # @param var_list Input list of variables.
      # @return An updated list of variables.
      def get_vars_body(node, var_list=[]):
          if isinstance(node, Node):
              if node.__class__.__name__ == 'Name':
                  for child in node.getChildren():
                      if child not in var_list:
                          var_list.append(child)
              for child in node.getChildren():
                  if isinstance(child, Node):
                      for child in node.getChildren():
                          var_list = get_vars_body(child, var_list)
                      break
  
          return var_list
  
      return get_vars_body(compiler.parse(source))
docs: Get list of variable names in a python expression.