def hashable(item):
"""Get return a hashable version of an item
If the item is natively hashable, return the item itself. If
it is not, return it dumped to a pickle string.
"""
try:
hash(item)
except TypeError:
item = pickle.dumps(item)
return item
评论列表
文章目录