nested-properties

How to get nested dictionary key value with .get()

How to get nested dictionary key value with .get() Question: With a simple dictionary like: myDict = {‘key1’:1, ‘key2’:2} I can safely use: print myDict.get(‘key3′) and even while ‘key3’ is not existent no errors will be thrown since .get() still returns None. Now how would I achieve the same simplicity with a nested keys dictionary: …

Total answers: 6

How to use a dot "." to access members of dictionary?

How to use a dot "." to access members of dictionary? Question: How do I make Python dictionary members accessible via a dot “.”? For example, instead of writing mydict[‘val’], I’d like to write mydict.val. Also I’d like to access nested dicts this way. For example mydict.mydict2.val would refer to mydict = { ‘mydict2’: { …

Total answers: 37