On Thu, Oct 7, 2010 at 12:13 PM, kj <no.em...@please.post> wrote: <snip> > It would facilitate the implementation of t() to have a simple test > for mutability. Is there one?
Non-default hashability is an approximate heuristic: def is_immutable(x): try: hash(x) except TypeError: return False else: klass = type(x) return klass is object or klass.__hash__ is not object.__hash__ Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list