def is_collection(obj):
 if isinstance(obj, basestring):
  return False
 return hasattr(obj, '__getitem__')

def is_collection ( obj ) : if isinstance ( obj , basestring ) : return False return hasattr ( obj , '__getitem__' )
tests if an object is a collection .