Weak Method Reference¶
Provides an implementation of a WeakMethodReference for weak references to functions and methods.
The standard weakref module in Python cannot store references to non-bound functions and should not be used to perform this task.
Code borrowed from the following places: http://code.activestate.com/recipes/81253/ http://stackoverflow.com/questions/3942303/how-does-a-python-set-check-if-two-objects-are-equal-what-methods-does-an-o
-
class
pygly.weak_method_reference.
WeakMethodReference
(function=None)[source]¶ Provides the ability to store a weak pointer to class members on top of the existing weakref functionality provided by python.
This class also provides comparison operators to allow proper usage in containers such as set([]).
The ability to change the weak reference is not supported to prevent mutability. This is important for container support as the object hash would change after storing it.
-
__init__
(function=None)[source]¶ Initialises the weak reference with a function or class method.
- Args:
- function: The object to store a weak reference to. This can be a class, object, method or function.
-