本文整理匯總了Python中_weakref.ref方法的典型用法代碼示例。如果您正苦於以下問題:Python _weakref.ref方法的具體用法?Python _weakref.ref怎麽用?Python _weakref.ref使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類_weakref
的用法示例。
在下文中一共展示了_weakref.ref方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def __init__(self, weakcontainer):
# Don't create cycles
self.weakcontainer = ref(weakcontainer)
示例2: __contains__
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def __contains__(self, item):
try:
wr = ref(item)
except TypeError:
return False
return wr in self.data
示例3: add
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def add(self, item):
if self._pending_removals:
self._commit_removals()
self.data.add(ref(item, self._remove))
示例4: remove
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def remove(self, item):
if self._pending_removals:
self._commit_removals()
self.data.remove(ref(item))
示例5: __isub__
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def __isub__(self, other):
if self._pending_removals:
self._commit_removals()
if self is other:
self.data.clear()
else:
self.data.difference_update(ref(item) for item in other)
return self
示例6: __iand__
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def __iand__(self, other):
if self._pending_removals:
self._commit_removals()
self.data.intersection_update(ref(item) for item in other)
return self
示例7: issubset
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def issubset(self, other):
return self.data.issubset(ref(item) for item in other)
示例8: __lt__
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def __lt__(self, other):
return self.data < set(ref(item) for item in other)
示例9: issuperset
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def issuperset(self, other):
return self.data.issuperset(ref(item) for item in other)
示例10: __eq__
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def __eq__(self, other):
if not isinstance(other, self.__class__):
return NotImplemented
return self.data == set(ref(item) for item in other)
示例11: __ixor__
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def __ixor__(self, other):
if self._pending_removals:
self._commit_removals()
if self is other:
self.data.clear()
else:
self.data.symmetric_difference_update(ref(item, self._remove) for item in other)
return self
示例12: difference_update
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def difference_update(self, other):
if self._pending_removals:
self._commit_removals()
if self is other:
self.data.clear()
else:
self.data.difference_update(ref(item) for item in other)
示例13: intersection_update
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def intersection_update(self, other):
if self._pending_removals:
self._commit_removals()
self.data.intersection_update(ref(item) for item in other)
示例14: __ge__
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def __ge__(self, other):
return self.data >= set(ref(item) for item in other)
示例15: symmetric_difference_update
# 需要導入模塊: import _weakref [as 別名]
# 或者: from _weakref import ref [as 別名]
def symmetric_difference_update(self, other):
if self._pending_removals:
self._commit_removals()
if self is other:
self.data.clear()
else:
self.data.symmetric_difference_update(ref(item) for item in other)