파이썬 튜플에서 차이점을 설정해야하지만 차이점은 내 튜플의 첫 번째 요소를 고려해야합니다. cmp 함수 나 키 함수를 파이썬의 차이점 집합 (또는 다른 집합 연산)에 전달 2.7
내가 라이브러리가 차이def difference(self, other):
"""Return the difference of two sets as a new Set.
(I.e. all elements that are in this set and not in the other.)
"""
result = self.__class__()
data = result._data
try:
otherdata = other._data
except AttributeError:
otherdata = Set(other)._data
value = True
for elt in ifilterfalse(otherdata.__contains__, self):
data[elt] = value
return result
를 확인하기 위해 itertools.ifilterfalse 기능을 사용하는 발견 sets.py 모듈에 파고이 클래스 접근
class Filedata(object):
def __init__(self, filename, path):
self.filename = filename
self.path = path + '\\' + filename
def __eq__(self, other):
return self.filename==other.filename
def __ne__(self, other):
return self.filename!=other.filename
def __call__(self):
return self.filename
def __repr__(self):
return self.filename
를 사용하여 (uncessfully) 내가 한이를 달성하기 위해
그러나 나는 이것으로 유용한 것을 할 수 없었습니다.
굉장! 고맙습니다. –