def getitem_or_default(l, idx, default=None):
    """
    gets the item at position idx or returns the default value
    :param list: list of things
    :param idx: position
    :param default: optional default value
    :return: thing at index idx or default
    """
    try:
        return l[idx]
    except IndexError:
        return default