You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A code formatter takes care of formatting your code so that it adheres to the styling standards. For Python, a popular code formatter is [black](https://black.readthedocs.io/en/stable/). Black is PEP 8 compliant but also adds some [own flavor](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html) to the code. Comparing code that has been formatted with black makes it easier to spot the differences. You can even try it out [online](https://black.vercel.app/?version=stable&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4ARsAnNdAD2IimZxl1N_WlkPinBFoXIfdFTaTVkGVeHShArYj9yPlDvwBA7LhGo8BvRQqDilPtgsfdKl-ha7EFp0Ma6lY_06IceKiVsJ3BpoICJM9wU1VJLD7l3qd5xTmo78LqThf9uibGWcWCD16LBOn0JK8rhhx_Gf2ClySDJtvm7zQJ1Z-Ipmv9D7I_zhjztfi2UTVsJp7917XToHBm2EoNZqyE8homtGskFIiif5EZthHQvvOj8S2gJx8_t_UpWp1ScpIsD_Xq83LX-B956I_EBIeNoGwZZPFC5zAIoMeiaC1jU-sdOHVucLJM_x-jkzMvK8Utdfvp9MMvKyTfb_BZoe0-FAc2ZVlXEpwYgJVAGdCXv3lQT4bpTXyBwDrDVrUeJDivSSwOvT8tlnuMrXoD1Sk2NZB5SHyNmZsfyAEqLALbUnhkX8hbt5U2yNQRDf1LQhuUIOii6k6H9wnDNRnBiQHUfzKfW1CLiThnuVFjlCxQhJ60u67n3EK38XxHkQdOocJXpBNO51E4-f9z2hj0EDTu_ScuqOiC9cI8qJ4grSZIOnnQLv9WPvmCzx5zib3JacesIxMVvZNQiljq_gL7udm1yeXQjENOrBWbfBEkv1P4izWeAysoJgZUhtZFwKFdoCGt2TXe3xQ-wVZFS5KoMPhGFDZGPKzpK15caQOnWobOHLKaL8eFA-qI44qZrMQ7sSLn04bYeenNR2Vxz7hvK0lJhkgKrpVfUnZrtF-e-ubeeUCThWus4jZbKlFBe2Kroz90Elij_UZBMFCcFo0CfIx5mGlrINrTJLhERszRMMDd39XsBDzpZIYV4TcG7HoMS_IF8aMAAAxI-5uTWXbUQAAY8F7QgAAP01Vc6xxGf7AgAAAAAEWVo=).
3
+
4
+
You first need to install black using
5
+
```
6
+
pip install black
7
+
```
8
+
You can then use black running it as
9
+
```
10
+
black Material_Part3_Formatter/example1.py
11
+
```
12
+
Please note that the formatter reformats the file in-place, that means, substituting the content of the original file!
13
+
14
+
Now you can check with flake8 if the file is compliant with PEP 8:
15
+
```
16
+
flake8 Material_Part3_Formatter/example1.py
17
+
```
18
+
You will notice that flake8 is not returning errors except a line length error for one of the comment lines: Note that black does not reformat comments other than inserting proper whitespace before and after the #.
19
+
20
+
## Black configuration
21
+
Sometimes you only want to check what black would actually reformat. In order to do so, run
22
+
```
23
+
black Material_Part2_Formatter/example1.py --diff
24
+
```
25
+
or
26
+
```
27
+
black Material_Part2_Formatter/example1.py --diff --color
The base directory where we are looking for the images. Defaults to None, which uses the XDG data directory if set or the current working directory otherwise.
12
+
:param pattern:
13
+
The naming pattern that the filename should match. Defaults to
14
+
"*.png". Can be used to allow other patterns or to only include
15
+
specific prefixes or suffixes.
16
+
:param recursive:
17
+
Whether to recurse into subdirectories.
18
+
:param limit:
19
+
The maximum number of images to be found. Defaults to 20.
0 commit comments