Browse Source

fix support for underscores in numbers in earlier pythons

master
adam j hartz 1 year ago
parent
commit
fb0019d746
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      takoshell/built_ins.py

+ 4
- 1
takoshell/built_ins.py View File

@@ -173,7 +173,10 @@ Fraction.__repr__ = Fraction.__str__ = _frac_repr
173 173
 def tako_num(x):
174 174
     nmode = builtins.__tako_env__['TAKO_SETTINGS'].number_mode
175 175
     if nmode in {'python', 'hybrid'}:
176
-        return ast.literal_eval(x)
176
+        try:
177
+            return ast.literal_eval(x)
178
+        except:
179
+            return ast.literal_eval(x.replace('_', ''))
177 180
     elif nmode == 'exact':
178 181
         try:
179 182
             return int(x)

Loading…
Cancel
Save