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

Oleg Broytman phd at phdru.name
Fri Jul 4 20:39:15 CEST 2014


On Fri, Jul 04, 2014 at 08:34:24PM +0200, Stefano Borini <stefano.borini at ferrara.linux.it> wrote:
> On Fri, Jul 04, 2014 at 08:20:18PM +0200, Oleg Broytman wrote:
> > Z=3, R=4 is far from being the same as
> > {"Z": 3, "R": 4}.
> 
> but dict(Z=3, R=4) is the same as {"Z": 3, "R": 4}. 
> this is exactly like tuple((2,3)) is the same as (2,3)
> See the similarity? the square brackets "call a constructor"
> on its content. This constructor is tuple if entries are not
> key=values (except for the single index case, of course), 
> and dict if entries are key=values.

   I didn't like the idea from the beginning and I am still against it.

d = dict
a[d(Z=3, R=4)]

   looks good enough for me without adding any magic to the language.

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            phd at phdru.name
           Programmers don't die, they just GOSUB without RETURN.


More information about the Python-ideas mailing list