[Python-Dev] syntactic shortcut - unpack to variably sized list

Nick Coghlan ncoghlan at iinet.net.au
Sat Nov 13 15:04:44 CET 2004

Nick Coghlan wrote:
> Nick Coghlan wrote:
>> Actually, if we went with the b) option, and the name 'popslice', I 
>> would suggest the following signature:
>> list.popslice(start=0, end, step=1)
> "Single argument is end value" was modelled on range(), FWIW.

Heh - turns out there is an actual slice() constructor with that 
start/end/step signature (I've never used it, so I didn't even know it 
was there).

Anyway, *if* we do anything about this (cleaner unpacking & removal of 
part of a list), I think 'popslice' or something similar is the right 
way to address it (rather than monkeying with syntax, which would only 
address slices at the start of the list anyway).

Any of the "a, b, *c = L" proponents want to come up with a candidate 
'list.popslice' patch for 2.5?

The implementation shouldn't be too hard - the "x = L[a:b:c]; del 
L[a:b:c]; return x" description should suffice for an implementation, 
too (using the C API, rather than actual Python, though).


Nick Coghlan               |     Brisbane, Australia
Email: ncoghlan at email.com  | Mobile: +61 409 573 268

More information about the Python-Dev mailing list