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

Nick Coghlan ncoghlan at gmail.com
Tue Nov 16 02:34:03 CET 2004


Martin v. Löwis wrote:
> 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.

Yes. Those two were on my list initially, but then I tried to figure out 
how using a slice would actually *work* for them. At which point, I took 
them back off the list - slice arguments just didn't make any sense.

So I think we're down to two things to implement - list.pop and 
array.pop. As you say, UserList.pop should just be a different way of 
spelling list.pop.

Cheers,
Nick.

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


More information about the Python-Dev mailing list