On Thu, Sep 1, 2011 at 5:28 PM, Richard D. Moores <rdmoo...@gmail.com> wrote: > Thanks, James, from your ideas I've come up with this function as a > general test for hashibility of any object: > > def is_hashable(object): > try: > if hash(object): > return True > except TypeError: > return False > > But is it? It returns True for ints, floats, sets, tuples, strings, > functions; and False for lists > > Dick
Are you sure? In my testing it returns False for sets, but True for frozensets as it should. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor