Python Documentation for the Weak Reference extension module

 

Module Functions

copyright () : string

This function returns a string with the copyright information.

license () : string

This function returns a string with the license information.

version () : string

This function returns a string with version information.

new (obj) : obj

Creates a new instance of a weak reference to the object passed in as a parameter to the function.
Example:
import weakref
obj = FooClass ()
wr = weakref.new (obj)
obj2 = wr.newref ()

Weak Reference Object

The object represents a weak reference to Python object.

newref (): obj

This method returns a new reference to the object held by the weak reference object. This method will return a reference to None if the original object no longer exists.

gettype (): obj

This method returns a new reference to the object type of the object held by the weak reference object. This method will return a reference to None if the original object no longer exists.

Operators supported by the Weak Reference Object

__getattr__ (self, name) : obj

Definition: Return a class attribute by name

Return: A borrowed reference to the attribute that was found; A reference to None if the attribute was not found

Parameters:

__cmp__ (self, thatObj) : number

Definition: Compares two weak reference objects

Return: a number

Parameters:

__repr__ (self) : string

Definition: Print out a readable representation of the weak reference object

Return: a new reference to the string that contains a readable representation of the weak reference object

Parameters: self - reference to the instance of a weak reference object

__hash__ (self): number

Definition: Returns a hash number for an instance of a weak reference object

Return: hash number for the C pointer to the weak referenced object. Two instances of the weak reference object that references the exact same Python object must return the same hash numbers.

Parameters: self - reference to the instance of a weak reference object