Feat: MOnumber creating with a integer string
This commit is contained in:
parent
204fdf755b
commit
b93f34bc38
@ -132,12 +132,15 @@ class MOnumber(Atom):
|
|||||||
Atom.__init__(self, value)
|
Atom.__init__(self, value)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
float(value)
|
v = float(value)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
raise MOError(
|
raise MOError(
|
||||||
"The value of an MOnumber need to be a int, a float, a Decimal or a decimal string",
|
"The value of an MOnumber need to be a int, a float, a Decimal or a decimal string",
|
||||||
f"(got {type(value)})",
|
f"(got {type(value)})",
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
if int(v) == v:
|
||||||
|
Atom.__init__(self, int(v))
|
||||||
else:
|
else:
|
||||||
Atom.__init__(self, Decimal(value))
|
Atom.__init__(self, Decimal(value))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user