How to tell if function was passed a list or a string?
Roy Smith
roy at panix.com
Wed May 17 18:57:32 EDT 2006
Ben Finney <bignose+hates-spam at benfinney.id.au> wrote:
> Currently there's no good duck-typing way to differentiate
> strings from other sequences.
I suppose you could do something like:
try:
foo.isalpha
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