| 1 |
# Getting Started |
| 2 |
|
| 3 |
New to _Black_? Don't worry, you've found the perfect place to get started! |
| 4 |
|
| 5 |
## Do you like the _Black_ code style? |
| 6 |
|
| 7 |
Before using _Black_ on some of your code, it might be a good idea to first understand |
| 8 |
how _Black_ will format your code. _Black_ isn't for everyone and you may find something |
| 9 |
that is a dealbreaker for you personally, which is okay! The current _Black_ code style |
| 10 |
[is described here](./the_black_code_style/current_style.md). |
| 11 |
|
| 12 |
## Try it out quickly |
| 13 |
|
| 14 |
If you want a quick taste of _Black_ without creating a file first, format a snippet |
| 15 |
from the command line: |
| 16 |
|
| 17 |
```sh |
| 18 |
black --code "x = { 'a':1,'b':2 }" |
| 19 |
``` |
| 20 |
|
| 21 |
## Installation |
| 22 |
|
| 23 |
_Black_ can be installed by running `pip install black`. It requires Python 3.10+ to |
| 24 |
run. |
| 25 |
|
| 26 |
If you use pipx, you can install Black with `pipx install black`. |
| 27 |
|
| 28 |
If you want to format Jupyter Notebooks, install with `pip install "black[jupyter]"`. |
| 29 |
See the [Jupyter Notebooks guide](./guides/using_black_with_jupyter_notebooks.md) for |
| 30 |
more details. |
| 31 |
|
| 32 |
If you can't wait for the latest _hotness_ and want to install from GitHub, use: |
| 33 |
|
| 34 |
`pip install git+https://github.com/psf/black` |
| 35 |
|
| 36 |
## Basic usage |
| 37 |
|
| 38 |
To get started right away with sensible defaults: |
| 39 |
|
| 40 |
```sh |
| 41 |
black {source_file_or_directory}... |
| 42 |
``` |
| 43 |
|
| 44 |
You can run _Black_ as a package if running it as a script doesn't work: |
| 45 |
|
| 46 |
```sh |
| 47 |
python -m black {source_file_or_directory}... |
| 48 |
``` |
| 49 |
|
| 50 |
## Next steps |
| 51 |
|
| 52 |
Took a look at [the _Black_ code style](./the_black_code_style/current_style.md) and |
| 53 |
tried out _Black_? Fantastic, you're ready for more. Why not explore some more on using |
| 54 |
_Black_ by reading |
| 55 |
[Usage and Configuration: The basics](./usage_and_configuration/the_basics.md). |
| 56 |
Alternatively, you can check out the |
| 57 |
[Introducing _Black_ to your project](./guides/introducing_black_to_your_project.md) |
| 58 |
guide. |