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
Copy file name to clipboardExpand all lines: episodes/style-guide.md
+62Lines changed: 62 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ Spaces (not tabs) are the preferred indentation method. Use 4 spaces per indenta
12
12
13
13
```python
14
14
# Correct
15
+
15
16
for x inrange(10):
16
17
print("x is", i)
17
18
@@ -20,6 +21,7 @@ def sayhello():
20
21
return x
21
22
22
23
# Wrong
24
+
23
25
for x inrange(10):
24
26
print("x is", x)
25
27
@@ -34,12 +36,14 @@ Imports should be on separate lines except when using the from syntax. Imports a
34
36
35
37
```python
36
38
# Correct
39
+
37
40
import numpy
38
41
import polars
39
42
40
43
from subprocess import Popen, PIPE
41
44
42
45
# Wrong
46
+
43
47
import numpy, polars
44
48
```
45
49
@@ -51,14 +55,17 @@ Imports should be grouped in the order shown below. An empty line should be plac
51
55
52
56
```python
53
57
# Standard library
58
+
54
59
import os
55
60
import math
56
61
57
62
# Third party
63
+
58
64
import numpy as np
59
65
import matplotlib.pyplot as plt
60
66
61
67
# Local package
68
+
62
69
from mypackage.utils import sayhello
63
70
```
64
71
@@ -82,3 +89,58 @@ def sayhello(x: str) -> str:
82
89
return greeting
83
90
```
84
91
92
+
## Naming conventions
93
+
94
+
Modules should have short lowercase names where underscores can be used to improve readability. Packages should also have short lowercase names but use of underscores is discouraged.
95
+
96
+
```bash
97
+
# Module names
98
+
99
+
downloader.py
100
+
101
+
file_downloader.py
102
+
```
103
+
104
+
```python
105
+
# Package names
106
+
107
+
import mypackage
108
+
```
109
+
110
+
Class names should use the capitalized words (or CapWords, CamelCase) convention.
111
+
112
+
```python
113
+
classDownloader:
114
+
...
115
+
116
+
dl = Downloader()
117
+
118
+
classFileDownloader:
119
+
...
120
+
121
+
file= FileDownloader()
122
+
```
123
+
124
+
Function and variable names should be lowercase with underscores to separate words for readability.
125
+
126
+
```python
127
+
defhello(x):
128
+
returnf"Hello {x}"
129
+
130
+
defsay_hello(x):
131
+
y =f"Hello {x}"
132
+
print(y)
133
+
```
134
+
135
+
Constants are usually defined at the module level and written in all capital letters.
0 commit comments