Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dict Update
#3
This is nested dictionary and I appears that you want to update subdictionary in schema: schema['keys']

schema = ({'type': 'dict', 'keys': {'2021': {'type': 'integer', 'default': 1234}}})
schema_update = ({'2022': {'type': 'integer', 'default': '5678'}})

schema['keys'].update(schema_update)

# schema is now:

{'type': 'dict',
 'keys': {'2021': {'type': 'integer', 'default': 1234}, 
          '2022': {'type': 'integer', 'default': '5678'}}}
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Dict Update - by dave0823 - Jan-02-2025, 01:28 AM
RE: Dict Update - by Pedroski55 - Jan-02-2025, 06:23 AM
RE: Dict Update - by dave0823 - Jan-02-2025, 02:18 PM
RE: Dict Update - by perfringo - Jan-02-2025, 07:45 AM
RE: Dict Update - by dave0823 - Jan-02-2025, 02:13 PM
RE: Dict Update - by dave0823 - Jan-02-2025, 02:28 PM
RE: Dict Update - by deanhystad - Jan-02-2025, 03:14 PM
RE: Dict Update - by dave0823 - Jan-02-2025, 03:48 PM
RE: Dict Update - by deanhystad - Jan-02-2025, 05:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Python + Google Sheet | Best way to update specific cells in a single Update()? Vokofe 1 3,858 Dec-16-2020, 05:26 AM
Last Post: Vokofe
  Sort a dict in dict cherry_cherry 4 104,279 Apr-08-2020, 12:25 PM
Last Post: perfringo
  update dict as per range of values anna 7 4,278 Sep-13-2019, 04:37 PM
Last Post: anna

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020