Python Glossary Русский

all Python 3gcfunction

gc.get_debug()

debugging

Returns the collector's current debug flags — an integer combining gc.DEBUG_* values.

Syntax

gc.get_debug()

The flags form a bit mask, so test them with &, not ==: get_debug() & gc.DEBUG_SAVEALL. DEBUG_LEAK is not a separate bit but a combination of several, so after set_debug(gc.DEBUG_LEAK) a check == gc.DEBUG_SAVEALL is false. The default is 0.

Examples

import gc
print(gc.get_debug())  # → 0
gc.set_debug(gc.DEBUG_LEAK)
flags = gc.get_debug()
print(flags == gc.DEBUG_SAVEALL, bool(flags & gc.DEBUG_SAVEALL))  # → False True
gc.set_debug(0)

See also

Open in the full glossarydocs.python.orgReport an inaccuracy