本文整理汇总了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)