You can pass a tuple of classes as the 2nd argument to isinstance.
>>> isinstance(u'hello', (basestring, str, unicode)) True
Raising the doctrine, you would also say that though;)
>>> help(isinstance) Help on built-in function isinstance in module __builtin__: isinstance(...) isinstance(object, class-or-type-or-tuple) -> bool Return whether an object is an instance of a class or of a subclass thereof. With a type as second argument, return whether that is the object type. The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for isinstance(x, A) or isinstance(x, B) or ... (etc.).
Glider
source share