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

Nick Coghlan ncoghlan at gmail.com
Mon Nov 15 14:41:59 CET 2004

Martin v. Löwis wrote:
> Armin Rigo wrote:
> Of course, whoever implements the change should make sure that slices
> are applicable consistently everwhere the documentation says they should
> be.

Random thought: the two uses of "["  and "]" in the sequence docs can 
get a little confusing. . . or maybe I'm just tired ;)

Anyway, the sequence and mutable sequence sections of the documentation 
don't reveal anything other than list.pop(). It seems to be the only 
normal method that accepts an index as an argument. Everything else 
looks to be dealt with via standard subscripts and the associated magic 

   Retrieval: x = L[i] | x = L.__getitem__(i)
   Setting: L[i] = x | L.__setitem__(i, x)
   Deletion: del L[i] | L.__delitem__(i, x)

So it looks like list.pop simply got left out because it wasn't a magic 
method, and the idea of permitting extended slicing for it just didn't 
come up (well, until now).**

Anyway, if this is implemented, array.pop and UserList.pop should allow 
slices, too, as they are described as working like list.pop.

The other container classes I've checked are either immutable, or don't 
allow indexed access beyond the basics (string, unicode, set, deque).


** Some items of possible historical interest:

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

More information about the Python-Dev mailing list