How to tell if function was passed a list or a string?

Roy Smith roy at
Thu May 18 00:57:32 CEST 2006

Ben Finney <bignose+hates-spam at> wrote:
> Currently there's no good duck-typing way to differentiate
> strings from other sequences.

I suppose you could do something like:

except AttributeError:
   print "foo is not a string"

but other than proving that you don't *have* to use isinstance(), I don't 
think that approach has much going for it.

More information about the Python-list mailing list