def is_string(obj):
 try:
  return isinstance(obj, basestring)
 except NameError:
  return isinstance(obj, str)

def is_string ( obj ) : try : return isinstance ( obj , basestring ) except NameError : return isinstance ( obj , str )
returns true if s is string or string-like object .