{ } Raw JSON

bundles / nbformat latest / nbformat / _struct / Struct / __setitem__

function

nbformat._struct:Struct.__setitem__

source: /nbformat/_struct.py:52

Signature

def __setitem__(self, key, value)

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')

Aliases

  • nbformat._struct.Struct.__setitem__