HNHacker News
TopNewBestAskShowJobs

cyberlis

18 karma · joined February 12, 2018

submissionscomments
cyberlis··on Show HN: Need feedback for my Python library to query dicts
You need to learn `ObjectPath` query language.

In `dictquery` I use simple and easy to understand language.

BUT My project is exercise and it is obviously not a competitor to mature, community supported libs.

That is why i do not want to compare `dictquery` to other libs

cyberlis··on Show HN: Need feedback for my Python library to query dicts
fixed by `mattcaldwell`
cyberlis··on Show HN: Need feedback for my Python library to query dicts
Yes. You are right. But I wanted the way to store my queries in any major database. And I wanted natural simple queries.

If I need to check my dictionary I want to use something similar to natural language.

lambdas and filters are greate, but not obvious at a glance.

If I want to check my dict: "Username is 'john' and age is greater than 23"

I will make this query: "`username` == 'john' and `age` > 23"

This query is obvious (i hope it is) for anyone from first glance

cyberlis··on Show HN: Need feedback for my Python library to query dicts
Yes, I wanted SQL like syntax and I'm happy it feels like this
cyberlis··on Show HN: Need feedback for my Python library to query dicts
I can use other symbol than back tick. But what symbol fits here better? what symbol would you use?
cyberlis··on Show HN: Need feedback for my Python library to query dicts
if you need a nested key value, you can use function:

    def get_dict_value(query_dict, dict_key, use_nested_keys=True,
                       key_separator='.', raise_keyerror=False):

theoretically i can make alternative syntax.

The plus of "stringly API" is that you can save your queries in database, or get it through web interface

cyberlis··on Show HN: Need feedback for my Python library to query dicts
Recently I was interested in parsing. Real parsing with grammars BNF LL LR.. :)

As exercise I implemented a library to query dicts.

This is my first python library and I'm looking for feedback and criticism

Especially, I need advice about public API

https://github.com/cyberlis/dictquery

You can install it with:

pip install dictquery

To write it I read:

Python Cookbook third edition. 2.18 Tokenizing Text, 2.19 Writing a Simple Recursive Descent Parser

All parsing related articles from https://eli.thegreenplace.net/2010/01/02/top-down-operator-p...

https://docs.python.org/3/library/re.html#writing-a-tokenize...