> On 3 Sep 2019, at 14:56, Paul Moore <p.f.mo...@gmail.com> wrote:
> 
> On Tue, 3 Sep 2019 at 13:38, None via Python-ideas
> <python-ideas@python.org> wrote:
> 
>> I really believe that a nested key retrieval mechanism should be a 
>> first-class offering of the standard library.  It is extremely common in the 
>> Python ecosystem to find developers working with data sets comprised of 
>> nested data structures.  Serializing and deserializing JSON is one of the 
>> most common functions developers do today, too.  As this is a common task 
>> being performed by hundreds of thousands of developers, wouldn't it better 
>> if we had one canonical way to do it (in the spirit of PEP-20 and having one 
>> obvious way to do things)?
> 
> There's a PyPI package, glom (https://pypi.org/project/glom/) that
> appears to do what you are after, as well as a lot more. Maybe that is
> something you should look into.

There are many more similar too. 

There's one in tri.declarative: 
https://trideclarative.readthedocs.io/en/latest/#get-set-attribute-given-a-path-string
 
<https://trideclarative.readthedocs.io/en/latest/#get-set-attribute-given-a-path-string>

There's one in pyrsistent: https://github.com/tobgu/pyrsistent#transformations 
<https://github.com/tobgu/pyrsistent#transformations> (the docs mostly talk 
about the transformation part because it's the thing you probably want in 
pyrsistent).

I agree fully with your point that use cases differ so the functions will 
differ. In glom the paths are "a.b.c", in tri.declarative they are "a__b__c" 
and in pyrsistent they are ['a', 'b', 'c']. All three makes sense from their 
respective use cases, and they can't be unified.

/ Anders
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/HDKIXEM5U7SRND7FH2VVKTBERZFIA766/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to