Comment

Chuck

isinstance will also return True if obj is a sublcass of tuble or list. It is usually considered safer to use isinstance unless you know for sure that the type will be a tuple or list and not a sublcass of those.

Parent comment

Peter Bengtsson

what benefit does isinstance give over type()? I'm not arguing, I'm asking. Personally I think: if isinstance(obj, (tuple,list)): is more confusing (especially for newcomers) than: if type(obj) in (types.ListType, types.TupleType):

Replies

Peter Bengtsson

That is very useful to know! Thank you.