Commits

Victor Kotseruba committed 7bf03f8

number expressions in strings

Comments (0)

Files changed (1)

 import functools
 
 
-_num_r = functools.partial(re.compile(r'(\d+(?:\.\d+)?)(px|em|pt)').sub, r'Number(\1, "\2")')
+_num_r = functools.partial(re.compile(r'(\d+(?:\.\d+)?)(px|em|pt)').sub, r"Number(\1, '\2')")
 _var_r = functools.partial(re.compile(r'!(?=\w+)').sub, '')
 
 
     
     
     def _expr(self, variables, match):
-        expr = ast.parse(_var_r(match.group(1))).body[0].value
+        s = _convert_s(match.group(1))
+        expr = ast.parse(_convert_s(match.group(1))).body[0].value
         variables.append(expr)
         return '%s'