Skip to content

Commit 1d1ebf5

Browse files
Side effects of changing a list
1 parent dc078e1 commit 1d1ebf5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/writing/style.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ The approach you use depends on
610610

611611
* Python 2.x vs. 3.x
612612
* Lists vs. iterators
613-
* Creating a new list vs. modifying the original list
613+
* Possible side effects of modifying the original list
614614

615615
Python 2.x vs. 3.x
616616
::::::::::::::::::
@@ -644,7 +644,7 @@ Creating a new list requires more work and uses more memory. If you a just going
644644
# Or (2.x)
645645
filtered_values = filter(lambda i: i != x, sequence)
646646
647-
# generators are lazy
647+
# generators don't create another list
648648
filtered_values = (value for value in sequence if value != x)
649649
# Or (3.x)
650650
filtered_values = filter(lambda i: i != x, sequence)
@@ -653,8 +653,8 @@ Creating a new list requires more work and uses more memory. If you a just going
653653
654654
655655
656-
Creating a new list vs. modifying the original list
657-
:::::::::::::::::::::::::::::::::::::::::::::::::::
656+
Possible side effects of modifying the original list
657+
::::::::::::::::::::::::::::::::::::::::::::::::::::
658658

659659
Modifying the original list can be risky if there are other variables referencing it. But you can use *slice assignment* if you really want to do that.
660660

0 commit comments

Comments
 (0)