def val(section, key):
    """ Return value of section[key] in units specified in configspec

        Args:
            section (:class:`qcobj.qconfigobj.QConfigObj`.Section`): instance
            key (string): valid key for `section`

        Returns:
            values in section[key] converted to units defined in configspec
    """
    value = section[key]
    units = section.main.configUnits(section, key)
    if isinstance(value, (list, tuple)):
        try:
            return [q.to(units).magnitude for q in value]
        except AttributeError:
            return [q for q in value]
    else:
        try:
            return value.to(units).magnitude
        except AttributeError:
            return value