def intid(id):
    """Convert id to an integer, if possible.

    Else id is returned unchanged. This is used to access ids in
    Gnucash data files easier. The ids are often integers.

    Example:
        >>> intid(5)
        5
        >>> intid('0012')
        12
        >>> intid('abc')
        'abc'

    """
    try:
        id2 = int(id)
    except Exception:
        id2 = id
    return id2