def tochar(v):
    """Check and convert value to a character"""
    if isinstance(v, str) and len(v) == 1:
        return v
    else:
        raise ValueError('Expected a character, but found %s' % v)