pyfunctools.at module

pyfunctools.at.at(obj: dict, path: str) any

Returns the value corresponding to path in obj

Parameters
  • obj (dict) – The dictionary we want to get the value from

  • path (str) – The path of the value that should be returned

Examples

>>> obj = { 'a': 1, 'b': { 'a': 1, 'b': [ 'a' ] } }
>>> at(obj, 'a')
1
>>> at(obj, 'b.a')
1
>>> at(obj, 'b.b')
[ 'a' ]
>>> at(obj, 'b.b.0')
'a'
>>> at(obj, 'b.b[0]')
'a'