-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.qmd
69 lines (49 loc) · 1.34 KB
/
example.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
title: "Black-formatter Example"
format:
html:
code-tools: true
jupyter: python3
filters:
- black-formatter
embed-resources: true
---
> Note: View the source of this document along with unformatted python codes by clicking `</> Code` on top-right corner to compare.
## Example 1
```{python}
#| label: hello_world
print ( 'hello, world' )
```
## Example 2
```{python}
#| label: is_unique
def is_unique(
s
):
s = list(s
)
s.sort()
for i in range(len(s) - 1):
if s[i] == s[i + 1]:
return 0
else:
return 1
```
[black defaults to 88 character per line](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length). But you can change this default behavior
by specifying `line-length` in the `pyproject.toml` file.
```{.toml filename='pyproject.toml'}
[tool.black]
line-length = 40
```
## Example 3
This extension works on non executable code blocks (i.e. `{.python}`) too.
```{.python}
def example_function(arg_1: str, arg_2: bool, arg_3: int = 0, arg_4: int = 1, arg_5: float = 0.0):
pass
```
## Example 4
```{.python #test_function}
def function(name, default=None, *args, variable="1123", a, b, c, employee, office, d, e, f, **kwargs):
"""This is function is created to demonstrate black"""
pass
```