Live data from Hacker News

Glom – Restructured Data for Python

sedimental.org

11–20 of 99 posts

Re: Glom – Restructured Data for Python

#12

This might have been unintentional, but I suspect "Spectre of Structure" and "Python's missing piece" refer to Nathan Marz's specter library for clojure [1], similarly touted as clojure's missing piece. I tend to agree in the case of specter, given the mind-boggling types of transformations that are easily (and simply) expressed in it (and often run faster than idiomatic clojure as well). Highly recommended if you ev…

Total coincidence! Reading the README, Nathan and I are definitely on the same wavelength though. When I get a chance I'll add it to the analogies doc: http://glom.readthedocs.io/en/latest/by_analogy.html :)

Re: Glom – Restructured Data for Python

#13
Looks really neat.

Striking a balance between ease of use / simplicity and powerful features is a tough exercise but you did well.

I can foresee the CLI being quite useful to do away with the run-of-the-mill sed / awk / grep [...] mess. Specifically for the less CLI inclined people out there.

Re: Glom – Restructured Data for Python

#15

Can it be used bidirectionally, without having to repeat the work? I have a need to transform between pairs of structures, in both directions, and ever since I found JsonGrammar ( https://github.com/MedeaMelana/JsonGrammar2 ) I've been pining for a Python version.

It depends on the complexity of the spec, but we've already done some programmatic building of glomspecs, so for many cases I think the answer is yes! Once we feel out the patterns I think glom will gain some utilities for this purpose.

Re: Glom – Restructured Data for Python

#16

Can it be used bidirectionally, without having to repeat the work? I have a need to transform between pairs of structures, in both directions, and ever since I found JsonGrammar ( https://github.com/MedeaMelana/JsonGrammar2 ) I've been pining for a Python version.

It depends on the complexity of the spec, but we've already done some programmatic building of glomspecs, so for many cases I think the answer is yes! Once we feel out the patterns I think glom will gain some utilities for this purpose.

Thanks, that's awesome!

Re: Glom – Restructured Data for Python

#18

Can it be used bidirectionally, without having to repeat the work? I have a need to transform between pairs of structures, in both directions, and ever since I found JsonGrammar ( https://github.com/MedeaMelana/JsonGrammar2 ) I've been pining for a Python version.

It seems like a subset of glom specs would be uniquely invertable. For example, the spec `{'c': 'a.b'}` could trivially invert to `{'a.b': 'c'}`. I'm not sure how you'd invert more complex specs which make function calls, e.g. sum or len.

Re: Glom – Restructured Data for Python

#20

I'm probably being dense, but I don't see a good description of the input data types supported - the CLI says "json or python". It would be great to have clarification if this is JSON only, or supports other data structures, or parsers could be plugged in?

From within Python, all objects are supported by default. If you can parse it, you can glom it. You can even register additional behaviors for specific types to keep your specs tight: http://glom.readthedocs.io/en/latest/api.html#setup-and-regi... (example: http://glom.readthedocs.io/en/latest/snippets.html#automatic...)

The CLI is in a pretty preliminary state, usable but not as robust as it will be in a few weeks. It only supports built-in parsers (JSON and Python literals) What formats are you thinking? YAML?

Post reply on HN