即使集合不可用,会员检查其他集合工作:
>>> set() in {frozenset()}
True
Run Code Online (Sandbox Code Playgroud)
我期望TypeError: unhashable type: 'set',与Python中的其他行为一致:
>>> set() in {} # doesn't work when checking in dict
TypeError: unhashable type: 'set'
>>> {} in {frozenset()} # looking up some other unhashable type doesn't work
TypeError: unhashable type: 'dict'
Run Code Online (Sandbox Code Playgroud)
那么,如何在其他集合中设置成员身份?