{ } Raw JSON

bundles / astropy latest / astropy / extern / configobj / configobj / Section / as_int

function

astropy.extern.configobj.configobj:Section.as_int

source: /astropy/extern/configobj/configobj.py :969

Signature

def   as_int ( self key )

Summary

A convenience method which coerces the specified value to an integer.

Extended Summary

If the value is an invalid literal for int, a ValueError will be raised.

>>> a = ConfigObj()
>>> a['a'] = 'fish'
>>> a.as_int('a')
Traceback (most recent call last):
ValueError: invalid literal for int() with base 10: 'fish'
>>> a['b'] = '1'
>>> a.as_int('b')
1
>>> a['b'] = '3.2'
>>> a.as_int('b')
Traceback (most recent call last):
ValueError: invalid literal for int() with base 10: '3.2'

Aliases

  • astropy.config.configuration.configobj.Section.as_int