On this page
  1. inspect.getattr_static
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

inspect.getattr_static

Prev: inspect.getasyncgenstate | Up: inspect | Next: inspect.getblock
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.getattr_static
Tags: #public #python3 #stdlib #inspect


Import

import inspect
from inspect import getattr_static

Signature & Overview

inspect.getattr_static(obj, attr, default=<object object at 0x1040b4700>)

Retrieve attributes without triggering dynamic lookup via the descriptor protocol, getattr or getattribute.

Usage

import inspect

class Boom:
    @property
    def val(self):
        raise RuntimeError("side effect!")

# Retrieves the property object itself without invoking Boom.val.fget
prop = inspect.getattr_static(Boom(), "val")
assert isinstance(prop, property)

Gotchas

REPL Inspect

from inspect import getattr_static
help(getattr_static)

Linked from

Related notes