Feat: MOnumber creating with a integer string

This commit is contained in:
Bertrand Benjamin 2019-07-17 09:53:03 +02:00
parent 219d923ff5
commit e52fec4057

View File

@ -132,12 +132,15 @@ class MOnumber(Atom):
Atom.__init__(self, value)
else:
try:
float(value)
v = float(value)
except (ValueError, TypeError):
raise MOError(
"The value of an MOnumber need to be a int, a float, a Decimal or a decimal string",
f"(got {type(value)})",
)
else:
if int(v) == v:
Atom.__init__(self, int(v))
else:
Atom.__init__(self, Decimal(value))