def getitem(obj, key=0, default=None):
    """Get first element of list or return default"""
    try:
        return obj[key]
    except:
        return default
Get first element of list or return default
pyspider/libs/utils.py