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

Popular posts from this blog

jasper reports - How to center align barcode using jasperreports and barcode4j -

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -