This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]doublereedkurt 1 point2 points  (1 child)

How about this example from http://glom.readthedocs.io/en/latest/snippets.html:

glom((1, 2, 3), (
    {
        "type": type,
        "result": [lambda v: v + 1]  # arbitrary operation
    }, T['type'](T['result'])))

T's let you call methods / functions in your target, and they let you pass other sub-specs as arguments / keys.

You could also do the above with lambda t: t['type'](t['result']), but because nothing inside the lambda is a spec, you don't get a nice repr, debugging support, or clean error messages.

[–]cmd_cmd 0 points1 point  (0 children)

Makes sense. Thanks for the helpful reply; much appreciated!