Get nested index from collection Examples -------- >>> nested_get(1, 'abc') 'b' >>> nested_get([1, 0], 'abc') ('b', 'a') >>> nested_get([[1, 0], [0, 1]], 'abc') (('b', 'a'), ('a', 'b'))
(ind, coll)
| 318 | |
| 319 | |
| 320 | def nested_get(ind, coll): |
| 321 | """Get nested index from collection |
| 322 | |
| 323 | Examples |
| 324 | -------- |
| 325 | |
| 326 | >>> nested_get(1, 'abc') |
| 327 | 'b' |
| 328 | >>> nested_get([1, 0], 'abc') |
| 329 | ('b', 'a') |
| 330 | >>> nested_get([[1, 0], [0, 1]], 'abc') |
| 331 | (('b', 'a'), ('a', 'b')) |
| 332 | """ |
| 333 | if isinstance(ind, list): |
| 334 | return tuple(nested_get(i, coll) for i in ind) |
| 335 | else: |
| 336 | return coll[ind] |
| 337 | |
| 338 | |
| 339 | def default_get_id(): |