From: Greg K. <gp...@be...> - 2002-03-06 13:27:53
|
Please, no. There are many short names that you could use that would avoid overloading the [] operator. Especially in Python, where one cannot trivially decide the type of a variable, the behavior should change as little as possible as the type of each variable changes. Here, the indexing operation changes completely if you change the last index from an int to an array. That means you have to execute the code to understand it -- one can't just look and assume from local syntax. Besides, you know some idiot is going to eventually write code that looks like this: def access(a, b, x): return a[b, x] # I think that a must be a 2-D array... # 1000 lines later... access(a, _I) # Whoops all my assumptions were wrong... > From: Travis Oliphant <oli...@ie...> > Subject: [Numpy-discussion] Adding a flag to allow integer array access and masking > > > I have not heard any feedback back on my proposal to add a final object to > the extended slice syntax to current Numeric to allow for unambiguous index > and mask-array access. > ...hidden from the user who would write: > > a[index_array, _I] = <values> > b = a[index_array, _I] > > or > > a[mask_array, _M] = <values> > b = a[mask_array, _M] > > where _M is a 0d signed byte array indicating that the mask_array should be > interpreted as a mask while _I is a 0d signed byte array indicating that the > index_array should be interpreted as a integers into the flattened version of > a. > > Other indexing schemes could be envisioned as well... |