[Python-ideas] PEP pre-draft: Support for indexing with keyword arguments
Alexander Belopolsky
alexander.belopolsky at gmail.com
Fri Jul 4 21:00:56 CEST 2014
On Fri, Jul 4, 2014 at 2:10 PM, Stefano Borini <
stefano.borini at ferrara.linux.it> wrote:
> I just added a new strategy. This one cuts the problem down.
>
> Strategy 4: Strict dictionary
>
Did anyone consider treating = inside [] in a similar way as : is treated
now. One can even (re/ab)use the slice object:
a[1, 2, 5:7, Z=42] -> a.__getitem__((1, 2, slice(5, 7, None), slice('Z',
'=', 42)))
This strategy would also offer a semi-readable back-porting solution:
>>> class C:
... def __getitem__(self, key):
... print(key)
...
>>> c = C()
>>> c['Z':'=':42]
slice('Z', '=', 42)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140704/3bea5b7e/attachment-0001.html>
More information about the Python-ideas
mailing list