def lease_to_id(lease):
    """Figure out if the argument is a Lease object, or the lease ID."""
    lease_id = 0
    if hasattr(lease, 'id'):
        lease_id = lease.id
    else:
        try:
            lease_id = int(lease)
        except TypeError:
            pass
    return lease_id
def lease_to_id ( lease ) : lease_id = 0 if hasattr ( lease , 'id' ) : lease_id = lease . id else : try : lease_id = int ( lease ) except TypeError : pass return lease_id
Figure out if the argument is a Lease object, or the lease ID.