Skip to content

Commit

Permalink
fix vocaburary error
Browse files Browse the repository at this point in the history
  • Loading branch information
ee0703 committed Dec 5, 2015
1 parent 0693d0c commit a5030fb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion project-guide/static.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{% endraw %}
```

* 错误的静态文件引用方式
* 不恰当的静态文件引用方式

```html
<img src="/static/img/pic1.jpg" alt="My image"/>
Expand Down
10 changes: 5 additions & 5 deletions style-guide/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 尽量不要直接将代码写在模块的顶层中,在执行主程序前应该总是检查 ``if __name__ == '__main__'`` , 这样当模块被导入时主程序就不会被执行.

```python
# 错误的写法(裸代码)
# 不推荐的写法(裸代码)
do_something()

# 正确的写法
Expand All @@ -23,7 +23,7 @@ if __name__ == '__main__':
* 尽量不要用```+```号拼接字符串, 使用```%s```模板或```join```拼接

```Python
# 错误的写法
# 不推荐的写法
print("Spam" + " eggs" + " and" + " spam")
# 正确写法, 使用 join
print(" ".join(["Spam","eggs","and","spam"]))
Expand All @@ -37,7 +37,7 @@ print("%s %s %s %s" % ("Spam", "eggs", "and", "spam"))
**注意: 复杂情况下不适用, 列表生成式过复杂反而会导致阅读和调试困难**

```Python
# 错误的写法
# 不推荐的写法
items = []
for item in directory:
items.append(item)
Expand All @@ -51,7 +51,7 @@ items = [item for item in directory]
```Python
numbers = [1, 2, 6, 9, 10 ...]

# 错误的写法
# 不推荐的写法
def even(numbers):
evens = []
for number in numbers:
Expand All @@ -76,7 +76,7 @@ regex_phone = re.compile(r'(13\d|14[57]|15[^4,\D]))$')
* 正则表达式使用前尽量先编译好

```Python
# 错误的写法, 不要使用未编译的正则
# 不推荐的写法, 不要使用未编译的正则
result = re.match(r'(^(13\d|14[57]|15[^4,\D]))$', my_phone)

# 正确的写法,使用前先编译
Expand Down
2 changes: 1 addition & 1 deletion style-guide/comment_and_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ are also implicitly created anytime a new section starts.
* 不要在文档注释复制函数定义原型, 而是具体描述其具体内容, 解释具体参数和返回值等

```python
# 错误的写法(不要写函数原型等废话)
# 不推荐的写法(不要写函数原型等废话)
def function(a, b):
"""function(a, b) -> list"""
... ...
Expand Down
22 changes: 11 additions & 11 deletions style-guide/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def main():
import os
import sys

# 错误的写法
# 不推荐的写法
import sys,os

# 正确的写法
Expand All @@ -72,7 +72,7 @@ from subprocess import Popen, PIPE
# 正确的写法
from foo.bar import Bar

# 错误的写法
# 不推荐的写法
from ..bar import Bar
```

Expand Down Expand Up @@ -116,7 +116,7 @@ x = x * 2 - 1
hypot2 = x * x + y * y
c = (a + b) * (a - b)

# 错误的写法
# 不推荐的写法
i=i+1
submitted +=1
x = x*2 - 1
Expand All @@ -131,7 +131,7 @@ c = (a+b) * (a-b)
def complex(real, imag):
pass

# 错误的写法
# 不推荐的写法
def complex(real,imag):
pass
```
Expand All @@ -143,7 +143,7 @@ def complex(real,imag):
def complex(real, imag=0.0):
pass

# 错误的写法
# 不推荐的写法
def complex(real, imag = 0.0):
pass
```
Expand All @@ -154,7 +154,7 @@ def complex(real, imag = 0.0):
# 正确的写法
spam(ham[1], {eggs: 2})

# 错误的写法
# 不推荐的写法
spam( ham[1], { eggs : 2 } )
```

Expand All @@ -164,7 +164,7 @@ spam( ham[1], { eggs : 2 } )
# 正确的写法
dict['key'] = list[index]

# 错误的写法
# 不推荐的写法
dict ['key'] = list [index]
```

Expand All @@ -176,7 +176,7 @@ x = 1
y = 2
long_variable = 3

# 错误的写法
# 不推荐的写法
x = 1
y = 2
long_variable = 3
Expand Down Expand Up @@ -221,7 +221,7 @@ do_first()
do_second()
do_third()

# 错误的写法
# 不推荐的写法
do_first();do_second();do_third();
```

Expand All @@ -232,7 +232,7 @@ do_first();do_second();do_third();
if foo == 'blah':
do_blah_thing()

# 错误的写法
# 不推荐的写法
if foo == 'blah': do_blash_thing()
```

Expand All @@ -253,7 +253,7 @@ if foo == 'blah': do_blash_thing()
# 正确的写法
x = x + 1 # 边框加粗一个像素

# 错误的写法(无意义的注释)
# 不推荐的写法(无意义的注释)
x = x + 1 # x加1
```

Expand Down
4 changes: 2 additions & 2 deletions style-guide/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

```python
if __name__ == '__main__':
# 错误的写法
# 不推荐的写法
# 尽量避免单字符变量名
s = "hello world!"
```
Expand All @@ -27,7 +27,7 @@ import htmlParser

```python
if __name__ == '__main__':
# 错误的写法
# 不推荐的写法
# 尽量避免l、O 等容易混淆的字母
l = 1
O = 0
Expand Down

0 comments on commit a5030fb

Please sign in to comment.