Alex Martelli wrote: > <[EMAIL PROTECTED]> wrote: > ... > > cookbook recipies of which there are already several good > > collections, but shorter things like, copy(sequence) is spelled > > "sequence[:]". > > No way: > > >>> from collections import deque > >>> d=deque([1,2,3]) > >>> d[:] > Traceback (most recent call last): > File "<stdin>", line 1, in ? > TypeError: sequence index must be integer > >>> deque(d) > deque([1, 2, 3]) > >>> > > I.e., NOT all sequences implement the unreadable x[:] form. > > The way that DOES work with all sequences is typeyouwant(sequence).
I'm sorry, I don't understand. Does deque return a sequence? The doc says it returns a deque object, and without further info I would not expect [:] to work. Is it a sequence because it has the same methods as a sequence? Whatever, I gather my old book is outdated and the blessed way now to (shallow) copy a sequence is (as you say) "typeyouwant(sequence)" which I will make a note of. Thanks for updating me. -- http://mail.python.org/mailman/listinfo/python-list