1 2 3 4 5 6 7 8 9 10 11 12 13 14
import types def is_string_like(maybe): """Test value to see if it acts like a string""" try: maybe+"" except TypeError: return 0 else: return 1 def is_list_or_tuple(maybe): return isinstance(maybe, (types.TupleType, types.ListType))