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

Armin Rigo arigo at tunes.org
Sun Nov 14 14:17:08 CET 2004


Hello Nick,

On Sat, Nov 13, 2004 at 10:05:23PM +1000, Nick Coghlan wrote:
> At the moment, list.pop is described as equivalent to:
> 
> x = L[i]; del L[i]; return x

Then the documentation is not exact: if it were really equivalent to the above
definition, then we could already do today:

  a, b = L.pop(slice(0,2))

because starting from Python 2.3,

  L[slice(0,2)]

is equivalent to

  L[0:2]

So who's wrong: the documentation of list.pop() or its implementation?  It
would be nicely regular if we could pop slices.


Armin


More information about the Python-Dev mailing list