Earlier quoted context omitted.
My thoughts also turned to toolz. Here's a example comparison: glom glom(target, ('system.planets', ['name'])) # ['earth', 'jupiter'] toolz list(pluck('name', get_in(('system', 'planets'), target))) # ['earth', 'jupiter']
The real advantage over toolz/get_in is in the breadth of types glom can support ( http://glom.readthedocs.io/en/latest/api.html#setup-and-regi... ), the extensive fallback behavior ( http://glom.readthedocs.io/en/latest/api.html#advanced-speci... ), and "T" specifier ( https://sedimental.org/glom_restructured_data.html#true-pyth... ), which allows performing object-oriented traversals and calls. Check the post for m…
Glom – Restructured Data for Python
81–90 of 99 posts
Re: Glom – Restructured Data for Python
#82Earlier quoted context omitted.
you know what's actually insufferable? taking pot shots at someone giving you something for free. either say thank you or move on. it's like yelling at your mom for making you breakfast in the morning: downright unseemly.
if the condescending tone of the top comment is ignored it becomes valuable feedback. good libraries/api's (free or otherwise) do not need to use marketing buzzwords to sell themselves when a clear demonstration of the functionality is usually more than enough. see the python requests library documentation for a good example http://docs.python-requests.org/en/master/
Re: Glom – Restructured Data for Python
#83It's a nice idea, but i never like writing what amounts to a DSL in strings in my code (yes, that applies to in-code SQL as well, although that's often unavoidable). I prefer the `get_in()` method from Toolz: http://toolz.readthedocs.io/en/latest/api.html#toolz.dicttoo...
I agree, I don't like the magic string approach (even if it is mostly just dot-notation attribute lookup). However, there is some good stuff here, and nested data lookup when value existence is unknown is a pain point for me. In addition to the string based lookup, it looks like there is an attempt at a pythonic approach: from glom import T spec = T['system']['planets'][-1].values() glom(target, spec) # ['jupiter', 6…
Re: Glom – Restructured Data for Python
#84This is pretty neat and is something I've been thinking about for a current project. Does anyone know if something similar exists in Java/Scala land?
Re: Glom – Restructured Data for Python
#85Earlier quoted context omitted.
The real advantage over toolz/get_in is in the breadth of types glom can support ( http://glom.readthedocs.io/en/latest/api.html#setup-and-regi... ), the extensive fallback behavior ( http://glom.readthedocs.io/en/latest/api.html#advanced-speci... ), and "T" specifier ( https://sedimental.org/glom_restructured_data.html#true-pyth... ), which allows performing object-oriented traversals and calls. Check the post for m…
What's the advantage of make_sentinel vs just doing _MISSING = object()?
Re: Glom – Restructured Data for Python
#86Earlier quoted context omitted.
My thoughts also turned to toolz. Here's a example comparison: glom glom(target, ('system.planets', ['name'])) # ['earth', 'jupiter'] toolz list(pluck('name', get_in(('system', 'planets'), target))) # ['earth', 'jupiter']
The real advantage over toolz/get_in is in the breadth of types glom can support ( http://glom.readthedocs.io/en/latest/api.html#setup-and-regi... ), the extensive fallback behavior ( http://glom.readthedocs.io/en/latest/api.html#advanced-speci... ), and "T" specifier ( https://sedimental.org/glom_restructured_data.html#true-pyth... ), which allows performing object-oriented traversals and calls. Check the post for m…
DSL in strings = bad
DSL in native syntax = good
Re: Glom – Restructured Data for Python
#87Earlier quoted context omitted.
I agree, I don't like the magic string approach (even if it is mostly just dot-notation attribute lookup). However, there is some good stuff here, and nested data lookup when value existence is unknown is a pain point for me. In addition to the string based lookup, it looks like there is an attempt at a pythonic approach: from glom import T spec = T['system']['planets'][-1].values() glom(target, spec) # ['jupiter', 6…
The other problem that T solves and nested doesn't is being able to reuse a spec. Once you have a spec, whether created with T or directly, you can call glom multiple times with the same spec, pass the spec to another function, tc.
Re: Glom – Restructured Data for Python
#88Re: Glom – Restructured Data for Python
#89It seems to me like the advantage to focus on here is the improved error / `None` handling, which will speed debugging and make handling expected edge cases easier. I've seen a lot of inexperienced developers tripped up entirely by this kind of data access, and seen plenty of experienced developers waste time debugging it because of the exact error cases the announcement references. The `T` object, which the article…
Libraries like these shine only if they have brilliant tracing and debugging capabilities; otherwise are too easy to reduce to literally a single function.
Re: Glom – Restructured Data for Python
#90Earlier quoted context omitted.
What's the advantage of make_sentinel vs just doing _MISSING = object()?
A Sentinel is guaranteed unique and distinct from all other objects.