You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python has the extremely-handy enumerate function, allowing you to iterate through a list and get the index of the current element. What's the team's view on adding similar functinality to Glom? Could be very useful for data exploration/validation (c.f. #7), so that you can find your way back to where a value came from.
Don't have a good idea of the best interface for this, but something like:
So if I was using this to power a validator ensuring that, say, no "b" was greater than 3, it could do:
for path, value in result:
if value > 3:
print(f"Warning: {path} greater than 3!")
It seems like the information needed to power this is all there already, based on the output of a recursive Inspect. Is there already some easy way of achieving this that I'm missing?
The text was updated successfully, but these errors were encountered:
Hey Eli! You're right that the state is all there, and that sounds like a perfectly fine application. Not sure if we want a top-level argument, or if it would be better to have it work at all levels like Inspect. We have an extension API in the works (#32), and that'll make adding these a lot easier.
It may be worth mentioning that if the structure of the data isn't well-known or highly-dynamic, remap may be better suited than glom, but in your example, it seems like you know what you're looking for :)
I'll keep this issue updated with developments, and let you know when the extension API is ready (that PR is our most active area of discussion/development atm, so it should be soon).
That's a good point about the top-level argument. I only figured out after writing this how Inspect-style wrappers can make use of glom's recursion to implement this kind of feature (which I think is extremely neat, by the way). Thanks for being so responsive, I'm looking forward to the update!
Python has the extremely-handy
enumerate
function, allowing you to iterate through a list and get the index of the current element. What's the team's view on adding similar functinality to Glom? Could be very useful for data exploration/validation (c.f. #7), so that you can find your way back to where a value came from.Don't have a good idea of the best interface for this, but something like:
So if I was
using
this to power a validator ensuring that, say, no "b" was greater than 3, it could do:It seems like the information needed to power this is all there already, based on the output of a recursive
Inspect
. Is there already some easy way of achieving this that I'm missing?The text was updated successfully, but these errors were encountered: