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

Rob Cliffe rob.cliffe at btinternet.com
Wed Jul 2 04:36:23 CEST 2014


On 01/07/2014 23:36, Stefano Borini wrote:
> Dear all,
>
> after the first mailing list feedback, and further private discussion 
> with Joseph Martinot-Lagarde, I drafted a first iteration of a PEP for 
> keyword arguments in indexing. The document is available here.
>
> https://github.com/stefanoborini/pep-keyword/blob/master/PEP-XXX.txt

A small bit of uninformed feedback (no charge :-) ):

1) Ahem, doesn't a[3] (usually) return the *fourth* element of a ?

2)

""" Compare e.g. a[1:3, Z=2] with a.get(slice(1,3,None), Z=2). """

I think this is slightly unfair as the second form can be abbreviated to  a.get(slice(1,3), Z=2),
just as the first is an abbreviation for  a[1:3:None, Z=2].

3) You may not consider this relevant.  But as an (I believe) 
intelligent reader, but one unfamiliar with the material, I cannot 
understand what your first example

""" low_accuracy_energy = computeEnergy(molecule, BasisSet[Z=3]) """

is about, and whether it is really (conceptually) related to indexing, 
or just a slick hack.  I guess it could be anything, depending on the 
implementation of __getitem__.

Best wishes,
Rob Cliffe


More information about the Python-ideas mailing list