Built-in Exceptions

ReferenceError — exception class

A weak-reference proxy is used after its referent has been collected. Unlike a proxy, weakref.ref can be called to obtain the referent or None. Keep a strong reference while operating on a live object. Catch ReferenceError when this category is the recovery boundary; do not rely on the exact human-readable message.

Formal Syntax & Structure

python syntaxpython
ReferenceError

Return Value

type

The class object ReferenceError; this reference documents the class identity, not a universal constructor signature.

Working Example

Example Snippetpython
import weakref, gcclass Item:    value=3item=Item()proxy=weakref.proxy(item)del itemgc.collect()try:    proxy.valueexcept ReferenceError as error:    print(type(error).__name__)
Python Reference