Live data from Hacker News

Glom – Restructured Data for Python

sedimental.org

81–90 of 99 posts

Re: Glom – Restructured Data for Python

#81
post #25

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…

What's the advantage of make_sentinel vs just doing _MISSING = object()?

Re: Glom – Restructured Data for Python

#82
post #68

Earlier 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/

I think the more practical piece of advice is for people like zestyping to constructively offer their (valid) perspective on writing style without personalizing the criticism. I recognize however that offering such advice may be a fruitless endeavor depending on the person (like expecting a leopard to change its spots). Source: zestyping needlessly insulted me in front of colleagues over 10 years ago and it still stings a bit :-D

Re: Glom – Restructured Data for Python

#83

It'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…

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

#85

Earlier 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()?

A Sentinel is guaranteed unique and distinct from all other objects.

Re: Glom – Restructured Data for Python

#86
post #25

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…

Sorry to double reply, but yes the "T" spec is exactly what I would want. IMO it's yet another step better than using a "spec" made of untyped nested lists and dicts.

DSL in strings = bad

DSL in native syntax = good

Re: Glom – Restructured Data for Python

#87
post #83

Earlier 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.

That’s called defining a function.

Re: Glom – Restructured Data for Python

#89
post #62

It 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…

I would like to see the author debugging an application with 10 levels of object wrapping that had one of the middle object’s name misspelled.

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

#90

Earlier 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.

I'm fairly sure object() also returns an object which is unique and distinct from all other objects. The only difference as far as I can see is that make_sentinel returns an object that has a unique and distinct type from all other objects, but I don't see why you'd be checking the type of your sentinels in Python.
Post reply on HN