On Tuesday 31 July 2007 18:43:42 Catherine wrote:

> def isTupleLike(obj):
>     try:
>         obj[0], obj[1]
>         if hasattr(obj, 'capitalize'):
>             return False # no strings, Unicode, etc.
>         return True
>     except:
>         return False

It is better using the correct tools:

>>> a = 'a'
>>> b = 123
>>> isinstance(a, basestring)
True
>>> isinstance(b, basestring)
False
>>> 


If you're willing to differentiate strings from the rest of types, then check 
for instances of basestring.  This is inherited by all string types (and 
should also be inherited by alternative implementations and derivations from 
those types).

-- 
Jorge Godoy      <[EMAIL PROTECTED]>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to