def _autotype(var):
    """Automatically convert strings to numerical types if possible.

    TODO: use ast module to do this better?
    """
    if type(var) is not str:
        return var
    if var.isdigit() or var.startswith('-') and var[1:].isdigit():
        return int(var)
    try:
        f = float(var)
        return f
    except ValueError:
        return var
