擅长:python、mysql、java
<p>无法创建同时等于<code>['a', 'b', 'c']</code>和<code>['b', 'a', 'c']</code>的常规列表。如果需要特殊的语义来进行<code>==</code>比较,则可能需要编写自己的类型:</p>
<pre><code>class wordset(object):
def __init__(self, words):
self.words = set(words)
def __eq__(self, other):
if isinstance(other, wordset):
return self.words == other.words
return self.words == set(other)
</code></pre>