On Mon, Oct 7, 2019 at 8:34 PM Steven D'Aprano <st...@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[...]
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ZB6OIFNPOUWNLUXGXBHWIFUDPM3T7F55/ Code of Conduct: http://python.org/psf/codeofconduct/