[Python-ideas] PEP pre-draft: Support for indexing with keyword arguments

Stefano Borini stefano.borini at ferrara.linux.it
Wed Jul 2 14:20:03 CEST 2014


On Wed, Jul 02, 2014 at 01:47:03PM +0200, Xavier Combelle wrote:
> in this case:
> 
>         C1: a[Z=3]      -> idx = {"Z": 3}             # P1/P2
> dictionary with single key
> 
> 
> as we can index with any object, I wonder how one could differency between
> the calls, a[z=3]
> and the actual a[{"Z":3}]. Do they should be return the same?

indeed you can't, and if I recall correctly I wrote it somewhere. The point is eventually 
if such distinction is worth considering or if, instead, the two cases should be handled
as degenerate (equivalent) notations. 

IMHO, they should be kept distinct, and this disqualifies that implementation strategy.
Too much magic would happen otherwise.


-- 
------------------------------------------------------------

-----BEGIN GEEK CODE BLOCK----- 
Version: 3.12         
GCS d- s+:--- a? C++++ UL++++ P+ L++++ E--- W- N+ o K- w---
O+ M- V- PS+ PE+ Y PGP++ t+++ 5 X- R* tv+ b DI-- D+
G e h++ r+ y*
------------------------------------------------------------



More information about the Python-ideas mailing list