This is a development version (9.14.0.dev) and may be unstable. Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython 9.14.0.dev / IPython / utils / ipstruct / Struct / __getattr__

function

IPython.utils.ipstruct:Struct.__getattr__

source: /IPython/utils/ipstruct.py :123

Signature

def   __getattr__ ( self key : str )  →  Any

Summary

Get an attr by calling dict.__getitem__.

Extended Summary

Like __setattr__, this method converts KeyError to AttributeError.

Examples

s = Struct(a=10)
s.a
type(s.get)
try:
    s.b
except AttributeError:
    print("I don't have that key")

Aliases

  • IPython.core.interactiveshell.Struct.__getattr__