You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
396 B
16 lines
396 B
from decimal import Decimal, InvalidOperation
|
|
|
|
def getInt(d, key, default):
|
|
""" Helper for dict.get to return the default on error. """
|
|
try:
|
|
return int(d.get(key, default))
|
|
except ValueError:
|
|
return default
|
|
|
|
def getDecimal(d, key, default):
|
|
""" Helper for dict.get to return the default on error. """
|
|
try:
|
|
return Decimal(d.get(key, default))
|
|
except InvalidOperation:
|
|
return default
|