| 1 |
# Add or remove imports |
| 2 |
|
| 3 |
## Adding an import to multiple files |
| 4 |
|
| 5 |
isort makes it easy to add an import statement across multiple files, |
| 6 |
while being assured it's correctly placed. |
| 7 |
|
| 8 |
To add an import to all files: |
| 9 |
|
| 10 |
```bash |
| 11 |
isort -a "from __future__ import print_function" *.py |
| 12 |
``` |
| 13 |
|
| 14 |
To add an import only to files that already have imports: |
| 15 |
|
| 16 |
```bash |
| 17 |
isort -a "from __future__ import print_function" --append-only *.py |
| 18 |
``` |
| 19 |
|
| 20 |
## Removing an import from multiple files |
| 21 |
|
| 22 |
isort also makes it easy to remove an import from multiple files, |
| 23 |
without having to be concerned with how it was originally formatted. |
| 24 |
|
| 25 |
From the command line: |
| 26 |
|
| 27 |
```bash |
| 28 |
isort --rm "os.system" *.py |
| 29 |
``` |