On 9/26/06, Simon Brunning <[EMAIL PROTECTED]> wrote: > On 26 Sep 2006 02:59:07 -0700, codefire <[EMAIL PROTECTED]> wrote: > > For example isinstance(a, int) works fine but isinstance(s, string) > > doesn't - because 'string is not known'. > > In this case, you want "str" rather than "string".
A couple of points to consider: Firstly, do you really need to use isinstance() at all? It's often not necessary. Consider a duck-typing approach instead - i.e. to just try using the object as a string, and to deal with exceptions arising from the possibility that it isn't. This approach would allow string-like objects as well as "real" strings. Secondly, if you *really* want to use isinstance(), "basestring" is the super-type of both "str" and "unicode", so it's more likely to be what you want. -- Cheers, Simon B, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list