36 def ensure(thing, desired_type):
37 """If thing is not of desired_type, construct a new desired_type from thing"""
38 return thing
if isinstance(thing, desired_type)
else desired_type(thing)
42 """Returns True when thing is an integer or float type."""
43 return is_int(thing)
or isinstance(thing, float)
46 if sys.version_info[0] < 3:
47 raise Exception(
"Python 3 or a more recent version is required.")
49 from amino.util3 import is_int, is_string, ensure_cstring