weakref
index
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py
Module Docs

Weak reference support for Python.
 
This module is an implementation of PEP 205:
 
http://www.python.org/dev/peps/pep-0205/

 
Modules
       
UserDict

 
Classes
       
UserDict.UserDict
WeakKeyDictionary
WeakValueDictionary
__builtin__.object
__builtin__.weakcallableproxy
__builtin__.weakproxy
__builtin__.weakref
_weakrefset.WeakSet
exceptions.StandardError(exceptions.Exception)
exceptions.ReferenceError

 
CallableProxyType = class weakcallableproxy(object)
     Methods defined here:
__abs__(...)
x.__abs__() <==> abs(x)
__add__(...)
x.__add__(y) <==> x+y
__and__(...)
x.__and__(y) <==> x&y
__call__(...)
x.__call__(...) <==> x(...)
__cmp__(...)
x.__cmp__(y) <==> cmp(x,y)
__contains__(...)
x.__contains__(y) <==> y in x
__delattr__(...)
x.__delattr__('name') <==> del x.name
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__delslice__(...)
x.__delslice__(i, j) <==> del x[i:j]
 
Use of negative indices is not supported.
__div__(...)
x.__div__(y) <==> x/y
__divmod__(...)
x.__divmod__(y) <==> divmod(x, y)
__float__(...)
x.__float__() <==> float(x)
__floordiv__(...)
x.__floordiv__(y) <==> x//y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__iadd__(...)
x.__iadd__(y) <==> x+=y
__iand__(...)
x.__iand__(y) <==> x&=y
__idiv__(...)
x.__idiv__(y) <==> x/=y
__ifloordiv__(...)
x.__ifloordiv__(y) <==> x//=y
__ilshift__(...)
x.__ilshift__(y) <==> x<<=y
__imod__(...)
x.__imod__(y) <==> x%=y
__imul__(...)
x.__imul__(y) <==> x*=y
__index__(...)
x[y:z] <==> x[y.__index__():z.__index__()]
__int__(...)
x.__int__() <==> int(x)
__invert__(...)
x.__invert__() <==> ~x
__ior__(...)
x.__ior__(y) <==> x|=y
__ipow__(...)
x.__ipow__(y) <==> x**=y
__irshift__(...)
x.__irshift__(y) <==> x>>=y
__isub__(...)
x.__isub__(y) <==> x-=y
__iter__(...)
x.__iter__() <==> iter(x)
__itruediv__(...)
x.__itruediv__(y) <==> x/=y
__ixor__(...)
x.__ixor__(y) <==> x^=y
__len__(...)
x.__len__() <==> len(x)
__long__(...)
x.__long__() <==> long(x)
__lshift__(...)
x.__lshift__(y) <==> x<<y
__mod__(...)
x.__mod__(y) <==> x%y
__mul__(...)
x.__mul__(y) <==> x*y
__neg__(...)
x.__neg__() <==> -x
__nonzero__(...)
x.__nonzero__() <==> x != 0
__or__(...)
x.__or__(y) <==> x|y
__pos__(...)
x.__pos__() <==> +x
__pow__(...)
x.__pow__(y[, z]) <==> pow(x, y[, z])
__radd__(...)
x.__radd__(y) <==> y+x
__rand__(...)
x.__rand__(y) <==> y&x
__rdiv__(...)
x.__rdiv__(y) <==> y/x
__rdivmod__(...)
x.__rdivmod__(y) <==> divmod(y, x)
__repr__(...)
x.__repr__() <==> repr(x)
__rfloordiv__(...)
x.__rfloordiv__(y) <==> y//x
__rlshift__(...)
x.__rlshift__(y) <==> y<<x
__rmod__(...)
x.__rmod__(y) <==> y%x
__rmul__(...)
x.__rmul__(y) <==> y*x
__ror__(...)
x.__ror__(y) <==> y|x
__rpow__(...)
y.__rpow__(x[, z]) <==> pow(x, y[, z])
__rrshift__(...)
x.__rrshift__(y) <==> y>>x
__rshift__(...)
x.__rshift__(y) <==> x>>y
__rsub__(...)
x.__rsub__(y) <==> y-x
__rtruediv__(...)
x.__rtruediv__(y) <==> y/x
__rxor__(...)
x.__rxor__(y) <==> y^x
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__setslice__(...)
x.__setslice__(i, j, y) <==> x[i:j]=y
 
Use  of negative indices is not supported.
__str__(...)
x.__str__() <==> str(x)
__sub__(...)
x.__sub__(y) <==> x-y
__truediv__(...)
x.__truediv__(y) <==> x/y
__xor__(...)
x.__xor__(y) <==> x^y
next(...)
x.next() -> the next value, or raise StopIteration

 
ProxyType = class weakproxy(object)
     Methods defined here:
__abs__(...)
x.__abs__() <==> abs(x)
__add__(...)
x.__add__(y) <==> x+y
__and__(...)
x.__and__(y) <==> x&y
__cmp__(...)
x.__cmp__(y) <==> cmp(x,y)
__contains__(...)
x.__contains__(y) <==> y in x
__delattr__(...)
x.__delattr__('name') <==> del x.name
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__delslice__(...)
x.__delslice__(i, j) <==> del x[i:j]
 
Use of negative indices is not supported.
__div__(...)
x.__div__(y) <==> x/y
__divmod__(...)
x.__divmod__(y) <==> divmod(x, y)
__float__(...)
x.__float__() <==> float(x)
__floordiv__(...)
x.__floordiv__(y) <==> x//y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__iadd__(...)
x.__iadd__(y) <==> x+=y
__iand__(...)
x.__iand__(y) <==> x&=y
__idiv__(...)
x.__idiv__(y) <==> x/=y
__ifloordiv__(...)
x.__ifloordiv__(y) <==> x//=y
__ilshift__(...)
x.__ilshift__(y) <==> x<<=y
__imod__(...)
x.__imod__(y) <==> x%=y
__imul__(...)
x.__imul__(y) <==> x*=y
__index__(...)
x[y:z] <==> x[y.__index__():z.__index__()]
__int__(...)
x.__int__() <==> int(x)
__invert__(...)
x.__invert__() <==> ~x
__ior__(...)
x.__ior__(y) <==> x|=y
__ipow__(...)
x.__ipow__(y) <==> x**=y
__irshift__(...)
x.__irshift__(y) <==> x>>=y
__isub__(...)
x.__isub__(y) <==> x-=y
__iter__(...)
x.__iter__() <==> iter(x)
__itruediv__(...)
x.__itruediv__(y) <==> x/=y
__ixor__(...)
x.__ixor__(y) <==> x^=y
__len__(...)
x.__len__() <==> len(x)
__long__(...)
x.__long__() <==> long(x)
__lshift__(...)
x.__lshift__(y) <==> x<<y
__mod__(...)
x.__mod__(y) <==> x%y
__mul__(...)
x.__mul__(y) <==> x*y
__neg__(...)
x.__neg__() <==> -x
__nonzero__(...)
x.__nonzero__() <==> x != 0
__or__(...)
x.__or__(y) <==> x|y
__pos__(...)
x.__pos__() <==> +x
__pow__(...)
x.__pow__(y[, z]) <==> pow(x, y[, z])
__radd__(...)
x.__radd__(y) <==> y+x
__rand__(...)
x.__rand__(y) <==> y&x
__rdiv__(...)
x.__rdiv__(y) <==> y/x
__rdivmod__(...)
x.__rdivmod__(y) <==> divmod(y, x)
__repr__(...)
x.__repr__() <==> repr(x)
__rfloordiv__(...)
x.__rfloordiv__(y) <==> y//x
__rlshift__(...)
x.__rlshift__(y) <==> y<<x
__rmod__(...)
x.__rmod__(y) <==> y%x
__rmul__(...)
x.__rmul__(y) <==> y*x
__ror__(...)
x.__ror__(y) <==> y|x
__rpow__(...)
y.__rpow__(x[, z]) <==> pow(x, y[, z])
__rrshift__(...)
x.__rrshift__(y) <==> y>>x
__rshift__(...)
x.__rshift__(y) <==> x>>y
__rsub__(...)
x.__rsub__(y) <==> y-x
__rtruediv__(...)
x.__rtruediv__(y) <==> y/x
__rxor__(...)
x.__rxor__(y) <==> y^x
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__setslice__(...)
x.__setslice__(i, j, y) <==> x[i:j]=y
 
Use  of negative indices is not supported.
__str__(...)
x.__str__() <==> str(x)
__sub__(...)
x.__sub__(y) <==> x-y
__truediv__(...)
x.__truediv__(y) <==> x/y
__unicode__(...)
__xor__(...)
x.__xor__(y) <==> x^y
next(...)
x.next() -> the next value, or raise StopIteration

 
class ReferenceError(StandardError)
    Weak ref proxy used after referent went away.
 
 
Method resolution order:
ReferenceError
StandardError
Exception
BaseException
__builtin__.object

Methods defined here:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data and other attributes defined here:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from BaseException:
__dict__
args
message

 
ReferenceType = class weakref(object)
     Methods defined here:
__call__(...)
x.__call__(...) <==> x(...)
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)

Data and other attributes defined here:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class WeakKeyDictionary(UserDict.UserDict)
    Mapping class that references keys weakly.
 
Entries in the dictionary will be discarded when there is no
longer a strong reference to the key. This can be used to
associate additional data with an object owned by other parts of
an application without adding attributes to those objects. This
can be especially useful with objects that override attribute
accesses.
 
  Methods defined here:
__contains__(self, key)
__copy__ = copy(self)
__deepcopy__(self, memo)
__delitem__(self, key)
__getitem__(self, key)
__init__(self, dict=None)
__iter__ = iterkeys(self)
__repr__(self)
__setitem__(self, key, value)
copy(self)
get(self, key, default=None)
has_key(self, key)
items(self)
iteritems(self)
iterkeyrefs(self)
Return an iterator that yields the weak references to the keys.
 
The references are not guaranteed to be 'live' at the time
they are used, so the result of calling the references needs
to be checked before being used.  This can be used to avoid
creating references that will cause the garbage collector to
keep the keys around longer than needed.
iterkeys(self)
itervalues(self)
keyrefs(self)
Return a list of weak references to the keys.
 
The references are not guaranteed to be 'live' at the time
they are used, so the result of calling the references needs
to be checked before being used.  This can be used to avoid
creating references that will cause the garbage collector to
keep the keys around longer than needed.
keys(self)
pop(self, key, *args)
popitem(self)
setdefault(self, key, default=None)
update(self, dict=None, **kwargs)

Methods inherited from UserDict.UserDict:
__cmp__(self, dict)
__len__(self)
clear(self)
values(self)

Class methods inherited from UserDict.UserDict:
fromkeys(cls, iterable, value=None) from __builtin__.classobj

Data and other attributes inherited from UserDict.UserDict:
__hash__ = None

 
class WeakSet(__builtin__.object)
     Methods defined here:
__and__ = intersection(self, other)
__contains__(self, item)
__eq__(self, other)
__ge__ = issuperset(self, other)
__gt__(self, other)
__iand__(self, other)
__init__(self, data=None)
__ior__(self, other)
__isub__(self, other)
__iter__(self)
__ixor__(self, other)
__le__ = issubset(self, other)
__len__(self)
__lt__(self, other)
__ne__(self, other)
__or__ = union(self, other)
__reduce__(self)
__sub__ = difference(self, other)
__xor__ = symmetric_difference(self, other)
add(self, item)
clear(self)
copy(self)
difference(self, other)
difference_update(self, other)
discard(self, item)
intersection(self, other)
intersection_update(self, other)
isdisjoint(self, other)
issubset(self, other)
issuperset(self, other)
pop(self)
remove(self, item)
symmetric_difference(self, other)
symmetric_difference_update(self, other)
union(self, other)
update(self, other)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
__hash__ = None

 
class WeakValueDictionary(UserDict.UserDict)
    Mapping class that references values weakly.
 
Entries in the dictionary will be discarded when no strong
reference to the value exists anymore
 
  Methods defined here:
__contains__(self, key)
__copy__ = copy(self)
__deepcopy__(self, memo)
__delitem__(self, key)
__getitem__(self, key)
__init__(self, *args, **kw)
__iter__ = iterkeys(self)
__repr__(self)
__setitem__(self, key, value)
clear(self)
copy(self)
get(self, key, default=None)
has_key(self, key)
items(self)
iteritems(self)
iterkeys(self)
itervaluerefs(self)
Return an iterator that yields the weak references to the values.
 
The references are not guaranteed to be 'live' at the time
they are used, so the result of calling the references needs
to be checked before being used.  This can be used to avoid
creating references that will cause the garbage collector to
keep the values around longer than needed.
itervalues(self)
pop(self, key, *args)
popitem(self)
setdefault(self, key, default=None)
update(self, dict=None, **kwargs)
valuerefs(self)
Return a list of weak references to the values.
 
The references are not guaranteed to be 'live' at the time
they are used, so the result of calling the references needs
to be checked before being used.  This can be used to avoid
creating references that will cause the garbage collector to
keep the values around longer than needed.
values(self)

Methods inherited from UserDict.UserDict:
__cmp__(self, dict)
__len__(self)
keys(self)

Class methods inherited from UserDict.UserDict:
fromkeys(cls, iterable, value=None) from __builtin__.classobj

Data and other attributes inherited from UserDict.UserDict:
__hash__ = None

 
ref = class weakref(object)
     Methods defined here:
__call__(...)
x.__call__(...) <==> x(...)
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature
__le__(...)
x.__le__(y) <==> x<=y
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)

Data and other attributes defined here:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
Functions
       
getweakrefcount(...)
getweakrefcount(object) -- return the number of weak references
to 'object'.
getweakrefs(...)
getweakrefs(object) -- return a list of all weak reference objects
that point to 'object'.
proxy(...)
proxy(object[, callback]) -- create a proxy object that weakly
references 'object'.  'callback', if given, is called with a
reference to the proxy when 'object' is about to be finalized.

 
Data
        ProxyTypes = (<type 'weakproxy'>, <type 'weakcallableproxy'>)
__all__ = ['ref', 'proxy', 'getweakrefcount', 'getweakrefs', 'WeakKeyDictionary', 'ReferenceError', 'ReferenceType', 'ProxyType', 'CallableProxyType', 'ProxyTypes', 'WeakValueDictionary', 'WeakSet']