lundi 10 août 2015

Check if variable is either a couple types? (str or list)

I know if i want to check for example if variable x is a str I will do

if type(x) is str:

but how can I check if x is either a string or list? So I can do this without adding another if branch

if type(x) is (str, list):
     pass
else:
     raise SomeError

Aucun commentaire:

Enregistrer un commentaire