Comment by divbzero
3 days ago
I suppose you could use the same trick with __ror__ and | (as long as the left-hand side doesn’t define __or__).
x = Model.objects.all() | by_pk | call(dict.values) | to_list | get('name') | _map(str.title) | log_debug | to_json
Sadly many things define the __or__ operator, including dicts and sets which are common to find in pipelines. (https://peps.python.org/pep-0584/ was a happy day for everyone but me!)
In practice, rshift gives a lot more flexibility! And you’d rarely chain after a numeric value.
It’s still useful in related situations. The following crime often finds its way into my $PYTHONSTARTUP:
and here the low precedence of | is useful.
Or overloading division like https://scapy.net/