Generating a random subsequence
tbryan at python.net
Wed Jan 9 05:30:42 CET 2002
Alex Martelli wrote:
> can become:
> templist = list(seq)
> for item in templist[:length]:
> returnSeq += item
> The += augmented operator dispatches appropriately to in-place or
> not-in-place mutation depending on LHO's mutable/immutable nature.
Is that just true of +=?
That is, if returnSeq is a list then, I can say
returnSeq = returnSeq + item
returnSeq.append( item )
returnSeq += item
You're saying that the last one is roughly equivalent to the second one and
not the first? Or are they all three equivalent?
More information about the Python-list