1
0
Fork 0

minimalist string to int/float function

This commit is contained in:
Kevin Matz 2018-10-25 16:18:54 -04:00
parent ffed6d35e3
commit 01e8a09925
1 changed files with 3 additions and 5 deletions

View File

@ -23,13 +23,11 @@ from CommentMacroListener import CommentMacroListener
logger = logging.getLogger("CommentMacro")
def num(string):
def num(s):
try:
num = int(string)
return num
return int(s)
except ValueError:
num = float(string)
return num
return float(s)
# https://raw.githubusercontent.com/jszheng/py3antlr4book/master/bin/pygrun