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") logger = logging.getLogger("CommentMacro")
def num(string): def num(s):
try: try:
num = int(string) return int(s)
return num
except ValueError: except ValueError:
num = float(string) return float(s)
return num
# https://raw.githubusercontent.com/jszheng/py3antlr4book/master/bin/pygrun # https://raw.githubusercontent.com/jszheng/py3antlr4book/master/bin/pygrun