Multiple "is" in Python -
I have a list with a few hundred objects, and I want to check if any newcomer object is already added to me The list is not (a similar object, but this is a very accurate example).
I have a dumb feeling like this:
def is_one_of (test_object, all_objects): all_objects for elm: if test_object is elm: return true return false Can not it be more beautiful?
Use any : < code> if any (all_objects have test_object for X): already looks like your code :)
Comments
Post a Comment