2.2.19. czekitout.convert.to_nonnegative_int

to_nonnegative_int(obj, obj_name)[source]

Convert input object to a nonnegative int.

If the input object is not a nonnegative integer, then an exception is raised with the message:

The object ``<obj_name>`` must be a nonnegative integer.

where <obj_name> is replaced by the contents of the string obj_name. In the case that an exception is raised, said exception is of the type TypeError if the input object is not an integer, otherwise said exception is of the type ValueError.

Parameters:
objany type

Input object.

obj_namestr

Name of the input object.

Returns:
resultint

The object resulting from the conversion.