minimalist string to int/float function
This commit is contained in:
parent
ffed6d35e3
commit
01e8a09925
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue