{ } Raw JSON

bundles / IPython 9.13.0 / 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")
I don't have that key

Aliases

  • IPython.core.interactiveshell.Struct.__getattr__