mardi 25 juin 2019

Is there a more compact way of writing these identical conditionals?

I want to check that the type of four variables is a particular type, and I have to do:

if (type(a) is not SomeType or
    type(b) is not SomeType or
    type(c) is not SomeType or
    type(d) is not SomeType):
    raise Exception("Not the correct types")

This feels repetitive. It seems there could be a better, less redundant way of doing this?

Aucun commentaire:

Enregistrer un commentaire