The following line is part of my code. I may be wrong, but it seems to be pythonic enough to me. However it is not clear, at first sight, what exactly it means. Is there a better code layout that would make it clearer? _idName is either a function or a DataFrame.
while  id1!="cancel" and ((id1 not in _idName.id.values) 
        if isinstance(_idName,_pd.DataFrame) else (_idName(id1) is None)):
    do something with the variables evaluated in the condition
 
     
     
    