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

bundles / IPython latest / IPython / utils / ipstruct / Struct / __setattr__

function

IPython.utils.ipstruct:Struct.__setattr__

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

Signature

def __setattr__(self, key: str, value: Any)

Summary

Set an attr with protection of class members.

Extended Summary

This calls self.__setitem__ but convert KeyError to AttributeError.

Examples

s = Struct()
s.a = 10
s.a
try:
    s.get = 10
except AttributeError:
    print("you can't set a class member")
✓
you can't set a class member

Aliases

  • IPython.core.interactiveshell.Struct.__setattr__