{ } Raw JSON

bundles / astropy 7.0.1 / astropy / extern / configobj / validate / is_integer

function

astropy.extern.configobj.validate:is_integer

source: /astropy/extern/configobj/validate.py :783

Signature

def   is_integer ( value min = None max = None )

Summary

A check that tests that a given value is an integer (int, or long) and optionally, between bounds. A negative value is accepted, while a float will fail.

Extended Summary

If the value is a string, then the conversion is done - if possible. Otherwise a VdtError is raised.

>>> vtor.check('integer', '-1')
-1
>>> vtor.check('integer', '0')
0
>>> vtor.check('integer', 9)
9
>>> vtor.check('integer', 'a')
Traceback (most recent call last):
VdtTypeError: the value "a" is of the wrong type.
>>> vtor.check('integer', '2.2')
Traceback (most recent call last):
VdtTypeError: the value "2.2" is of the wrong type.
>>> vtor.check('integer(10)', '20')
20
>>> vtor.check('integer(max=20)', '15')
15
>>> vtor.check('integer(10)', '9')
Traceback (most recent call last):
VdtValueTooSmallError: the value "9" is too small.
>>> vtor.check('integer(10)', 9)
Traceback (most recent call last):
VdtValueTooSmallError: the value "9" is too small.
>>> vtor.check('integer(max=20)', '35')
Traceback (most recent call last):
VdtValueTooBigError: the value "35" is too big.
>>> vtor.check('integer(max=20)', 35)
Traceback (most recent call last):
VdtValueTooBigError: the value "35" is too big.
>>> vtor.check('integer(0, 9)', False)
0

Aliases

  • astropy.config.configuration.validate.is_integer