Skip to content

Commit bbe0572

Browse files
committed
add pep content
1 parent 4ea00d4 commit bbe0572

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

Material_Part1_PEP/PEP_right_or_wrong

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Naming conventions
2+
3+
Which of the below naming conventions are correct?
4+
5+
- [ ] `class my-first-analysis:`
6+
- [ ] `class my_first_analysis:`
7+
- [ ] `class Myfirstanalysis:`
8+
- [ ] `class MyFirstAnalysis:`

PEP_recommendations/README.md

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# PEP recommendations
2+
3+
## What is a PEP?
4+
5+
Find out about the purpose of PEPs (Python Enhancement Proposals) on the [pep site](https://peps.python.org/pep-0001/). Short answer: These are documents helping to organize the evolution of the Python language in the community.
6+
7+
You can find a list of PEPs [here](https://peps.python.org/).
8+
9+
## What is PEP 8?
10+
11+
[PEP 8](https://peps.python.org/pep-0008/) is a meta-PEP = a PEP about other PEPs. PEP 8 specifies Python styling do's and dont's.
12+
13+
## PEP 8 summary
14+
15+
1. Line length
16+
Don't write lines that are very long. Reason: Often you would use multiple windows next to each other and that makes it hard to read code (and possibly lead to introduction of bugs).
17+
PEP 8 recommends lines no longer than 79 characters, but 90 is also a good number.
18+
19+
1. Alignment of code
20+
Make use of indentation when using continuation lines:
21+
22+
foo = long_function_name(var_one, var_two,
23+
var_three, var_four)
24+
25+
instead of
26+
27+
foo = long_function_name(var_one, var_two,
28+
var_three, var_four)
29+
30+
You may also use hanging indents
31+
32+
foo = long_function_name(
33+
var_one, var_two,
34+
var_three, var_four)
35+
36+
1. Break line before binary operator
37+
38+
income = (gross_wages
39+
+ taxable_interest
40+
+ (dividends - qualified_dividends)
41+
- ira_deduction
42+
- student_loan_interest)
43+
44+
instead of
45+
46+
income = (gross_wages +
47+
taxable_interest +
48+
(dividends - qualified_dividends) -
49+
ira_deduction -
50+
student_loan_interest)
51+
52+
1. Blank lines:
53+
- two blank lines after `import` statements
54+
- two blank lines between functions and classes
55+
- one blank line between methods of classes
56+
57+
import os
58+
59+
60+
def greeting():
61+
print("Hello world!")
62+
63+
64+
def goodbye():
65+
print("See ya!")
66+
67+
instead of
68+
69+
import os
70+
71+
def greeting():
72+
print("Hello world!")
73+
74+
def goodbye():
75+
print("See ya!")
76+
77+
and
78+
79+
def something():
80+
pass
81+
82+
83+
class MyClass:
84+
85+
def my_method():
86+
pass
87+
88+
def some_other():
89+
pass
90+
91+
instead of
92+
93+
def something():
94+
pass
95+
96+
class MyClass:
97+
def my_method():
98+
pass
99+
def some_other():
100+
pass
101+
102+
103+
## What is PEP 257?
104+
105+
[PEP 257](https://peps.python.org/pep-0257/) specifies styling of Python docstrings.
106+
107+
## PEP 257 summary
108+
109+
## PEP 20
110+
111+
The Zen of Python. Type `import this` in your Python console.

0 commit comments

Comments
 (0)