On Mon, Oct 7, 2019 at 8:34 PM Steven D'Aprano <steve@pearwood.info> wrote:
On Mon, Oct 07, 2019 at 02:22:22PM +0100, Rhodri James wrote:
On 04/10/2019 20:34, Caleb Donovick wrote:
``` where_x_1 = db[x=1] ```
which would be equivalent to the existing syntax
where_x_1 = db[{'x': 1}]
[Rhodi]
OK, I'm not sure what you're trying to do here, which all on its own says that what you're doing isn't self-explanatory.
I think it is pretty self-explanatory. Caleb wants to allow passing arguments to ``__getitem__`` by keyword, not just position.
Subscripting obj[x] is, effectively, an alternate form of function call syntax with a number of differences and restrictions compared to obj(x):
- calls the ``__getitem__`` dunder instead of ``__call__`` dunder
- by convention, is supposed to be used for item indexing, key lookups, and type annotations, rather than arbitrary uses
- the syntax is different, and highly restricted, compared to regular function calls:
1. there is no zero-argument form
d[...]