It's really not a worthwhile win.  It captures a tiny fraction of Pandas style filtering while complicating the syntax of Python. Here's another Pandas filter:

      db[db.x < 1] 

No help there with the next syntax.  Here's another:

      db[(db.x == 1) | (db.y == 2)]

A much better idea doesn't require any changes in Python, just a clever class method. Pandas did this for a while, but deprecated it because... reasons. Still, the OP is free to create his version:



    db['x=1 or y=2']

You can bikeshed the spelling of those predicates, but it doesn't matter, they are just strings that you can see however you decide is best.

On Mon, Oct 7, 2019, 8:38 PM Steven D'Aprano <> wrote:
On Tue, Oct 08, 2019 at 09:19:07AM +1100, Cameron Simpson wrote:
> On 07Oct2019 10:56, Joao S. O. Bueno <> wrote:
> >So, in short, your idea is to allow "=" signs inside `[]` get notation to
> >be translated
> >to dicts on the call,
> Subjectively that seems like a tiny tiny win. I'm quite -1 on this idea;
> language spec bloat to neglible gain.

As per Caleb's initial post, this is how Pandas currently does it:

    db[db['x'] == 1]

Replacing that with db[x=1] seems like a HUGE win to me.

Even db[{'x': 1}] is pretty clunky.

Python-ideas mailing list --
To unsubscribe send an email to
Message archived at
Code of Conduct: