On 4/15/2020 2:57 PM, Ivan Pozdeev via Python-Dev wrote:

On 16.04.2020 0:34, Glenn Linderman wrote:
On 4/15/2020 12:47 PM, Ivan Pozdeev via Python-Dev wrote:
When writing a proof-of-concept implementation, however, I bumped into the need to distinguish which of the child objects are containers (thus need to be wrapped as well) and which are the leaves (thus need to be returned as is). I guess this is going to be application-specific. And the same problem will arise with any implementation, not only a wrapper.

Do the child objects truly need to be wrapped, or just accessed?

They need to be wrapped on the fly, to support nested  ".key" accesses.

That sounds like an implementation detail... that is one possible implementation.
The parent object could alternately look inside, it seems.


Thanks for your comments though, they inspired a thought.

The problem with the glom syntax versus the dotted syntax is that the minimal syntax is bulky.

obj.abc.def.ghi     versus   glom( obj, 'abc.def.ghi')

The problem with attribute syntax is the conflict with regular attributes, and the limitation of valid identifier characters. Glom probably doesn't have these problems.

"Glom syntax" still excludes the delimiter, whatever it is, from use in keys. So it's still a further limitation compared to the JSON spec.

That could be handled with escaping, when necessary.



So my new thought is that we need a new syntax.  The minimal existing syntax might be

obj._('abc.def.ghi')     or maybe   obj['abc.def.ghi']

although the latter would conflict with regular dict lookups, but obj isn't a regular dict, so that might not matter.


A new syntax might be:

obj.'abc.def.ghi'


In any of these syntaxes, one could enhance it to use variables in some spots similarly to f-strings (but from the beginning, so no 'f' would be required)

foo = 'def'
obj.'abc.{foo}.ghi'

would access the same item as previous examples.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/3A5V62LY3DAPAREZMB7MVRYX4432NR7F/
Code of Conduct: http://python.org/psf/codeofconduct/
--
Regards,
Ivan
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/76BY73UZRU2QUTEMDQDD6J4TIVSOWKJ7/
Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/BG3MJYLHGS4E4QDRRPSOJHXBEBPSHRQC/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to