fal at libero.it
Wed Dec 15 10:43:16 CET 2010
On 14/12/2010, Brett Ritter and Dave Angel wrote:
> Francesco Loffredo wrote:
>>> mylist[:] = [x for x in mylist if x != "something"]
>>> mylist = [x for x in mylist if x != "something"]
> mylist[:] is a slice of mylist (you know that). If you ASSIGN it to
> something, you'll get a copy of that slice, but if you modify it
> you're modifying the list in place.
> On the left side of an assignment, a slice operator specifies which part of an existing object gets replaced by the right side. So
> whenever you have a list that's referred to by more than one symbol, you may want to use a syntax like this.
> The slice operator does a very different thing inside an expression (eg. on the right side of an assignment).
*THANK YOU BOTH!*
This is something I overlooked, and I'm very happy you made me understand it.
Nessun virus nel messaggio.
Controllato da AVG - www.avg.com
Versione: 10.0.1170 / Database dei virus: 426/3315 - Data di rilascio: 14/12/2010
More information about the Tutor