|
|
Subscribe / Log in / New account

Improving Python's SimpleNamespace

Improving Python's SimpleNamespace

Posted May 2, 2020 8:03 UTC (Sat) by PhilippWendler (subscriber, #126612)
In reply to: Improving Python's SimpleNamespace by NYKevin
Parent article: Improving Python's SimpleNamespace

Especially in complex cases JSONPath is a nice standard for this, it would allow you to write 'clothing.mens.shoes.extra_wide.quantity' here but also supports arrays etc. (like if shoes where an array and you need to find the element in it that has the extra_wide property set to true, and then retrieve quantity from it). I have not yet used it from a Python project, but it seems there are libraries implementing.


to post comments

Improving Python's SimpleNamespace

Posted May 3, 2020 11:24 UTC (Sun) by mathstuf (subscriber, #69389) [Link]

I've always ended up using the JSON Pointer standard for stuff like this. Are they basically the same, with Pointer preferring `/` rather than `.`. But it seems there are quite a few existing standards for this. `-` truly would be an xkcd#927 instance :) .


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds