Our great sponsors
-
glom
☄️ Python's nested data operator (and CLI), for all your declarative restructuring needs. Got data? Glom it! ☄️
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
If your project requires writing this sort of code a lot, there are third-party libraries that can make it a bit easier. One example that comes to mind is glom (take a look at their tutorial).
Now, the thing you're doing can be done with something called lenses. But they're rather hard to learn, and really not something I would recommend for a beginner. But there's packages like this which enables you to compose a function that will succinctly parse the thing you're interested in and give you good error messages.