Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 297ee1a

Browse files
authored
we've met somewhere, i remember ..
1 parent 2d56363 commit 297ee1a

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

‎README.md

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
<h2 id="2">愚蠢的一致性是小心灵的大地精</h2>
4848

49-
代码风格一致性当然重要,读起来滑溜溜,跟做大保健一样爽,但有时也要有自己的判断。
49+
代码风格一致性固然重要,毕竟读起来滑溜溜,跟做大保健一样爽,但有时也要有自己的判断。
5050

5151
例如以下场景:
5252

@@ -60,41 +60,55 @@
6060

6161
一个缩进级别四个空格。
6262

63-
* 连续行使用两种方式使封装元素成为一行:括号内垂直隐式连接和悬挂式缩进,使用悬挂式缩进应该注意第一行不应该有参数,连续行要使用进一步的缩进来区分。
63+
* 连续行使用两种方式使封装元素成为一行:括号内垂直隐式连接 & 悬挂式缩进。 使用悬挂式缩进应该注意第一行不应该有参数,连续行要使用进一步的缩进来区分。
6464

6565
```Python
66-
# Aligned with opening delimiter.
66+
67+
是:
68+
69+
# 括号内隐式连接,垂直对齐
6770
foo = long_function_name(var_one, var_two,
6871
var_three, var_four)
6972

70-
# More indentation included to distinguish this from the rest.
73+
# 悬挂缩进,进一步缩进区分其他语句
7174
def long_function_name(
7275
var_one, var_two, var_three,
7376
var_four):
7477
print(var_one)
7578

76-
# Hanging indents should add a level.
79+
# 悬挂缩进,一般是四个空格,但非必须
7780
foo = long_function_name(
7881
var_one, var_two,
7982
var_three, var_four)
83+
84+
否:
85+
86+
# 括号内隐式连接,没有垂直对齐时,第一行的参数被禁止
87+
foo = long_function_name(var_one, var_two,
88+
var_three, var_four)
89+
90+
# 悬挂缩进,需要进一步的缩进区分其他行
91+
def long_function_name(
92+
var_one, var_two, var_three,
93+
var_four):
94+
print(var_one)
8095
```
8196

82-
* 当 if 语句过长需要换行时,以下处理方法可以采用。
97+
* 当 if 语句过长时,可选的处理方式,但不限于此:
8398

84-
```Python
85-
# No extra indentation.
99+
```python
100+
# 不使用额外缩进
86101
if (this_is_one_thing and
87102
that_is_another_thing):
88103
do_something()
89104

90-
# Add a comment, which will provide some distinction in editors
91-
# supporting syntax highlighting.
105+
# 增加注释区分,支持语法高亮
92106
if (this_is_one_thing and
93107
that_is_another_thing):
94108
# Since both conditions are true, we can frobnicate.
95109
do_something()
96-
97-
# Add some extra indentation on the conditional continuation line.
110+
111+
# 条件连续行额外缩进
98112
if (this_is_one_thing
99113
and that_is_another_thing):
100114
do_something()
@@ -112,6 +126,17 @@ result = some_function_that_takes_arguments(
112126
'd', 'e', 'f',
113127
)
114128
```
129+
或者
130+
```python
131+
my_list = [
132+
1, 2, 3,
133+
4, 5, 6,
134+
]
135+
result = some_function_that_takes_arguments(
136+
'a', 'b', 'c',
137+
'd', 'e', 'f',
138+
)
139+
```
115140

116141
<h3 id="3.2">A 罩杯还是 E 罩杯 ?</h3>
117142

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /