List slice assignment and custom sequences

Erik Max Francis max at alcyone.com
Sun Nov 3 01:38:29 EST 2002


Ronald Oussoren wrote:

> No, I want to replace part of a sequence by another sequence.

If the sequence that your splicing into is a custom type, then it's
going to depend on whether such splicing is implemented and how. 
Presumably it would want a sequence on the right-hand side of the same
type as the left-hand side.

> I don't
> understand _why_ the RHS must be a list if the LHS is one. It doesn't
> even allow a tuple, even though tuples can be used instead of lists in
> almost all code that treats the sequence as read-only.

It just sounds like common sense to me; the splicing operation should
take the same type of sequence on the right-hand side as the left. 
Since Python allows you trivial conversion from _any_ sequence to a list
with the list function/type, it seems like a non-problem to me if the
right-hand side isn't a list to start with.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Weakness of attitude becomes weakness of character.
\__/ Albert Einstein
    WebVal / http://www.alcyone.com/pyos/webval/
 URL scanner, maintainer, and validator in Python.



More information about the Python-list mailing list