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

"Martin v. Löwis" martin at v.loewis.de
Mon Nov 15 22:34:23 CET 2004


Nick Coghlan wrote:
> 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. 

This isn't really true:

s.index(x[, i[, j]])  	
    return smallest k such that s[k] == x and i <= k < j  	
s.insert(i, x)  	
    same as s[i:i] = [x]

However, I don't think this naturally extends to slices:
for index, there is no <= relationship for slices (atleast
not a natural one), and for insert, you can use slices as
start- and end-index of a slice.

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

Right. For UserList, it probably falls out naturally.

Regards,
Martin


More information about the Python-Dev mailing list