Live data from Hacker News

Glom – Restructured Data for Python

sedimental.org

91–99 of 99 posts

Re: Glom – Restructured Data for Python

#91

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 nice __repr__ is the main thing

Re: Glom – Restructured Data for Python

#92
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.

http://glom.readthedocs.io/en/latest/api.html#debugging

affordances to add tracing prints, or drop into a pdb at any level

The Inspect specifier type provides a way to get visibility into glom’s evaluation of a specification, enabling debugging of those tricky problems that may arise with unexpected data.

Inspect can be inserted into an existing spec in one of two ways. First, as a wrapper around the spec in question, or second, as an argument-less placeholder wherever a spec could be.

Inspect supports several modes, controlled by keyword arguments. Its default, no-argument mode, simply echos the state of the glom at the point where it appears:

Re: Glom – Restructured Data for Python

#93

Earlier quoted context omitted.

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.

Hehe, boltons.typeutils.make_sentinel should really be documented better for more experienced developers. A few small advantages: a nice repr, pickleability, and (back to the first advantage really) good rendering in a Sphinx autodoc context. :)

Re: Glom – Restructured Data for Python

#94

Earlier quoted context omitted.

I feel the same way, although my instinct is generally to build a custom generator. Only costs a couple lines but is plain old python and quite explicit target = {'system': {'planets': [{'name': 'earth', 'moons': 1}, {'name': 'jupiter', 'moons': 69}]}} glom(target, {'moon_count': ('system.planets', ['moons'], sum)}) # vs def iter_moons(t): for planet in target['system']['planets']: yield planet['moons'] sum(iter_moon…

For simple cases like this it doesn't even cost a couple lines as sum() can take a generator expression: sum(planet['moons'] for planet in target['system']['planets'])

Combining ideas from parent and grandparent:

  sum(planet.get('moons', 0) for planet in target['system']['planets'])

Re: Glom – Restructured Data for Python

#96

Earlier quoted context omitted.

You're yellin at a tutorial man. You gotta let some flavor text slide. :) That said, I'm no liar. Kurt and I (as a team), really did write stuff leading up to glom in 2013 (years ago), and have written stuff like it enough times that I've lost count (countless :P). If this isn't research, I don't know what is. Heck, I'm even getting a fun little peer review!

don't sweat it dude. I've noticed a lot of people on hn are crabby assholes for absolutely no good reason. like on the post linking to Google's codelabs (where there are hundreds of tuts about all sorts of things in the Google ecosystem) there were only two comments and they were complaints. and recall that every time an electron app is posted almost every comment is whining about the performance. and every time a ru…

This needs to become a copy pasta + a version where we s/hn/reddit/g and every friggin salty post needs it shoved to them.

Re: Glom – Restructured Data for Python

#97

The writing style is just insufferable. Even the API documentation is littered with hyperbole and self-congratulation. We get it, you're proud of your work and extremely proud of yourself. > "as simple and powerful as glom" > "big things come in small packages" > "small API with big functionality" > "power is only surpassed by its intuitiveness" > "simplicity is only surpassed by its utility" > "shortest-named featur…

Hey Ka-Ping! Maybe I did get carried away :) How I wish one could publish a dry document and expect people to read all the way to the bottom. I've published enough libraries to know that's not the case. glom's free software so it's all there, as "shown" as can be. But referring you to the code wouldn't be very considerate either. Instead, here's this literate code version that I prepared in advance. Hopefully this wi…

I was frustrated. I apologize. I do still believe the frequency and intensity of hyperbolic language is a real obstacle to understanding and appreciating your project, and I hope you take that feedback to heart. But to call you "extremely proud of yourself" was unnecessarily personal, and I'm sorry I said that.

Re: Glom – Restructured Data for Python

#98
post #68

Earlier quoted context omitted.

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

I think that practical advice is good.

Publicly deriding me as having an irreparable character flaw, based on something I said over ten years ago, which I can't possibly defend or apologize for because I have no idea who you are or what you're referring to—doesn't that seem a little low, though?

It sounds like this is still bothering you after all this time. Please consider reaching out to me (my e-mail address is my HN username at gmail); I'd be glad if we could sort this out in a private conversation. I can't promise that I'll take back what I said without knowing what it was, but I will do my best to understand what you experienced and why it was upsetting to you.

Re: Glom – Restructured Data for Python

#99

This is really cool. Did you ever consider an API to do the reverse - to insert a value at a particular point in the data? My interest stems from this issue[0] on the Ruby issue tracker to make a symmetrical method to Hash#dig (which does something similar to, but more limited than glom) called Hash#bury. The problem in the issue was that inserting a value at a given index in an array proved difficult and unnatural i…

Perhaps assoc_in or update_in from the Toolz library fits this?

https://toolz.readthedocs.io/en/latest/api.html#toolz.dictto... https://toolz.readthedocs.io/en/latest/api.html#toolz.dictto...

Post reply on HN