{ } Raw JSON

bundles / IPython 9.13.0 / 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__