News for hackers. Stuff that matters.
Re:Specific ways to write better Python (2017) by carapace on Saturday June 20, 2020 @02:55PM (#23585939)
> Assigning to a list slice will replace that range in the original sequence with what's referenced even if their lengths are different.

Not only that, but you can assign to a slice with a stride:

    In [1]: r = list(range(10))                                                                                           

    In [2]: r                                                                                                             
    Out[2]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

    In [3]: r[1::3] = 10, 20, 30                                                                                          

    In [4]: r                                                                                                             
    Out[4]: [0, 10, 2, 3, 20, 5, 6, 30, 8, 9]

There are no comments on this comment yet.