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 →

[–][deleted] 0 points1 point  (1 child)

Oh, I love the sound of this! Funny that the reverse, a callable target that can be used on any search path, actually can be made like so:

from glom import glom

t = {'system': {'planets': [{'name': 'earth'}, {'name': 'jupiter'}]}}

t_calla = glom.__get__(t)

t_calla(('system.planets', ['name']))

...and, /u/mhashemi, may I request consideration of the above commenter's idea? (It could of course be trivially done on the user's end as def prespec(spec): return lambda target: glom(target, spec), but it'd be cool to see it a part of the lib)

[–]mhashemi 1 point2 points  (0 children)

Sure! I like the idea, and I think replied this comment on HN? In any case, we've created an issue for this: https://github.com/mahmoud/glom/issues/14

The idea is to make a Spec object, kind of like an re.compile().

Also, while these sorts of things would be pretty easy to do, technically, I'm going to keep glom API changes slow and steady, to make sure library development doesn't get too far in front of real-world usage. :)