Pincer-org /
Pincer
| 1 | # Copyright Pincer 2021-Present |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 2 | # Full MIT License can be found in `LICENSE` at the project root. |
||
| 3 | |||
| 4 | from typing import Any, Callable, Iterable, List, T |
||
| 5 | |||
| 6 | |||
| 7 | def replace( |
||
|
0 ignored issues
–
show
|
|||
| 8 | func: Callable[[Any], bool], iter_: Iterable[T], new_item: T |
||
|
0 ignored issues
–
show
|
|||
| 9 | ) -> List[T]: |
||
| 10 | return [item if func(item) else new_item for item in iter_] |
||
| 11 |