A tool to search for Python code using jQuery-like selectors

by caioariedeon 2/8/16, 7:49 PMwith 2 comments
by canduon 2/8/16, 9:12 PM

Interesting idea, and a great exercise for learning more about parsing, CSS selectors, and command-line interfaces.

One point of (hopefully) constructive criticism: I'm not completely sold on the CSS selector syntax. Attribute selectors are semantically meaningful in the DOM, not as much so in Python.

Providing a more Pythonic query language might make it easier for users to guess the purpose of queries and to build complex queries of their own. For instance:

    class * extends IntegerField
    class FloatField
    class FloatField: def *
    class FloatField: def to*
    from collections import Counter
or perhaps:

    class FloatField: def to*(foo)
    for * in *: if * is None
(or perhaps even `for $1 in : if $1 is None`. There are probably better ways than what I described to express the wildcard part, especially if you want to distinguish these from `args`, `kwargs`...)

Anyways, it's always awesome to see people putting their work out there, and I hope you'll continue to do so!