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

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


On Fri, Jul 04, 2014 at 08:10:51PM +0200, Stefano Borini <stefano.borini at ferrara.linux.it> wrote:
>     C1. a[Z=3]            -> idx = {"Z": 3}
>     C2. a[Z=3, R=4]       -> idx = {"Z"=3, "R"=4}

   Huh? Shouldn't it be 
C2. a[Z=3, R=4]       -> idx = {"Z": 3, "R": 4}
   ???

> Cons:
>     - degeneracy of a[{"Z": 3, "R": 4}] with a[Z=3, R=4], but the same degeneracy exists
>       for a[(2,3)] and a[2,3].

   There is no degeneration in the second case. Tuples are created by
commas, not parentheses (except for an empty tuple), hence (2,3) and 2,3
are simply the same thing. While Z=3, R=4 is far from being the same as
{"Z": 3, "R": 4}.

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