Ricardo Aráoz wrote:
> Kent Johnson wrote:
>> or use slice assignment:
>> tmpSegs[:] = [ seg.split(self.ElemSep) for seg in tmpSegs ]
> 
> Won't the slice assignment create a new list and then assign it to the
> old list (which the OP is trying to avoid)?

Yes, it will, thanks! You can assign a generator expression to the list:
tmpSegs[:] = ( seg.split(self.ElemSep) for seg in tmpSegs )

I don't know if that creates a temp list or assigns directly into the 
old list though. At the byte-code level at least it seems to assign the 
iterator to the slice.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to