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 / __setitem__

function

IPython.utils.ipstruct:Struct.__setitem__

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

Signature

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

Summary

Set an item with check for allownew.

Examples

s = Struct()
s['a'] = 10
s.allow_new_attr(False)
s['a'] = 10
s['a']
try:
    s['b'] = 20
except KeyError:
    print('this is not allowed')
✓
this is not allowed

Aliases

  • IPython.core.interactiveshell.Struct.__setitem__