getattr(cursor, 'location') is equivalent to cursor.location if hasattr(cursor, 'location') else None