def _preprocess(config_string):
 results = [u'[__COMMENTS__]']
 counter = itertools.count(0)
 section_re = re.compile(u'^(\\[[^\\]]+\\])\\s*(.+)$')
 blank_line_re = re.compile(u'^\\s*$')
 comment_re = re.compile(u'^(#|;)')
 inline_comment_re = re.compile(u' ;')
 def newlines(match):
  return (u'__BLANK%d__ =' % next(counter))
 def comments(match):
  if (match.group(1) == u'#'):
   return (u'__HASH%d__ =' % next(counter))
  elif (match.group(1) == u';'):
   return (u'__SEMICOLON%d__ =' % next(counter))
 def inlinecomments(match):
  return (u'\n__INLINE%d__ =' % next(counter))
 def sections(match):
  return (u'%s\n__SECTION%d__ = %s' % (match.group(1), next(counter), match.group(2)))
 for line in config_string.splitlines():
  line = blank_line_re.sub(newlines, line)
  line = section_re.sub(sections, line)
  line = comment_re.sub(comments, line)
  line = inline_comment_re.sub(inlinecomments, line)
  results.append(line)
 return u'\n'.join(results)

def _preprocess ( config_string ) : results = [ u'[__COMMENTS__]' ] counter = itertools . count ( 0 ) section_re = re . compile ( u'^(\\[[^\\]]+\\])\\s*(.+)$' ) blank_line_re = re . compile ( u'^\\s*$' ) comment_re = re . compile ( u'^(#|;)' ) inline_comment_re = re . compile ( u' ;' ) def newlines ( match ) : return ( u'__BLANK%d__ =' % next ( counter ) ) def comments ( match ) : if ( match . group ( 1 ) == u'#' ) : return ( u'__HASH%d__ =' % next ( counter ) ) elif ( match . group ( 1 ) == u';' ) : return ( u'__SEMICOLON%d__ =' % next ( counter ) ) def inlinecomments ( match ) : return ( u'\n__INLINE%d__ =' % next ( counter ) ) def sections ( match ) : return ( u'%s\n__SECTION%d__ = %s' % ( match . group ( 1 ) , next ( counter ) , match . group ( 2 ) ) ) for line in config_string . splitlines ( ) : line = blank_line_re . sub ( newlines , line ) line = section_re . sub ( sections , line ) line = comment_re . sub ( comments , line ) line = inline_comment_re . sub ( inlinecomments , line ) results . append ( line ) return u'\n' . join ( results )
prepare expr for solving by making sure that differentiation is done so that only func remains in unevaluated derivatives and that doit is applied to all other derivatives .