How do I distinguish a string from a sequence?
Paul Moore
gustav at morpheus.demon.co.uk
Sat Sep 29 17:02:06 EDT 2001
On Fri, 28 Sep 2001 15:39:50 -0400, "Tim Peters" <tim.one at home.com> wrote:
>[Paul Moore]
>> But I'm not sure how best to distinguish a string from a sequence
>> - after all, a string *is* a sequence.
>
>I'd check for
>
> type(args) in types.StringTypes
>
>under the theory that it gets the job done <wink>.
Yes, that sounds like a reasonable practical solution (assuming 2.2, where
StringTypes exists - otherwise I can just use (StringType, UnicodeType)). But
Skip's idea of trying the call and catching the exception is probably even
better.
Paul.
More information about the Python-list
mailing list