
I just found myself writing a method like this: def __getitem__(self, index): return self.data[(Ellipsis,) + index + (slice(),)] I would have liked to write it like this: self.data[..., index, :] because that would make it much easier to see what's being done. However, that won't work if index is itself a tuple of index elements. So I'd like to be able to do this: self.data[..., *index, :] -- Greg

On Tue, Sep 14, 2010 at 9:54 AM, Mike Graham <mikegraham@gmail.com> wrote: ..
I believe this and other unpacking generalizations are implemented in issue #2292: http://bugs.python.org/issue2292

Alexander Belopolsky wrote:
I believe this and other unpacking generalizations are implemented in issue #2292: http://bugs.python.org/issue2292
Yes, it appears so. Did a PEP for that ever materialise, or is everyone waiting until after the moratorium? -- Greg

On 9/14/2010 6:16 PM, Greg Ewing wrote:
The only PEP I know of is the one for what has been done: http://www.python.org/dev/peps/pep-3132/ Extended Iterable Unpacking -- Terry Jan Reedy

Mike Graham wrote:
It would be handy to be able to use it when making other tuples, yes. There's a particularly strong motivation for it in relation to indexes, though, because otherwise you not only end up having to use ugly (foo,) constructs, but you lose the ability to use any of the special indexing syntax. There's also a performance penalty if you end up having to look up 'slice' a bunch of times. -- Greg

On Tue, Sep 14, 2010 at 9:54 AM, Mike Graham <mikegraham@gmail.com> wrote: ..
I believe this and other unpacking generalizations are implemented in issue #2292: http://bugs.python.org/issue2292

Alexander Belopolsky wrote:
I believe this and other unpacking generalizations are implemented in issue #2292: http://bugs.python.org/issue2292
Yes, it appears so. Did a PEP for that ever materialise, or is everyone waiting until after the moratorium? -- Greg

On 9/14/2010 6:16 PM, Greg Ewing wrote:
The only PEP I know of is the one for what has been done: http://www.python.org/dev/peps/pep-3132/ Extended Iterable Unpacking -- Terry Jan Reedy

Mike Graham wrote:
It would be handy to be able to use it when making other tuples, yes. There's a particularly strong motivation for it in relation to indexes, though, because otherwise you not only end up having to use ugly (foo,) constructs, but you lose the ability to use any of the special indexing syntax. There's also a performance penalty if you end up having to look up 'slice' a bunch of times. -- Greg
participants (4)
-
Alexander Belopolsky
-
Greg Ewing
-
Mike Graham
-
Terry Reedy