Skip to content

Commit 484c66a

Browse files
committed
Better dedupe() and declarative description
Addresses concerns raised by @TheNeuralBit and @veprbl in PR amontalenti#23.
1 parent 132c7e5 commit 484c66a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ It's always better to have a `lib.time` module for time-related functions than t
349349

350350
### Declarative vs imperative
351351

352-
You should prefer declarative to imperative programming. If you aren't familiar with the difference, Python's [functional programming guide][func] includes some good details and examples of how to use this style effectively.
352+
You should prefer declarative to imperative programming. This is code that says **what** you want to do, rather than code that describes **how** to do it. Python's [functional programming guide][func] includes some good details and examples of how to use this style effectively.
353353

354354
[func]: https://docs.python.org/3/howto/functional.html
355355

@@ -387,7 +387,7 @@ David Beazley has [a YouTube tutorial on generators entitled "Generators: The Fi
387387

388388
This is a concept that we can borrow from the functional programming community. These kinds of functions and generators are alternatively described as "side-effect free", "referentially transparent", or as having "immutable inputs/outputs".
389389

390-
As a simple example, you should **never** write code like this:
390+
As a simple example, you should avoid code like this:
391391

392392
```python
393393
# bad
@@ -401,7 +401,7 @@ def dedupe(items):
401401
else:
402402
seen.add(item)
403403
num_dupes = len(dupe_positions)
404-
for idx in sorted(dupe_positions, reverse=True):
404+
for idx in reversed(dupe_positions):
405405
items.pop(idx)
406406
return items, num_dupes
407407
```

0 commit comments

Comments
 (0)