Skip to content

Commit 47585ad

Browse files
committed
Merge branch 'master' of github.com:ecmadao/Coding-Guide
2 parents 8340f6c + 8cec672 commit 47585ad

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

Notes/Python/Python进阶/Magic Python.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ print(json.dumps(database))
5757
# {"users": {"name": "ecmadao"}}
5858
```
5959

60+
使用这种方式更容易理解:
61+
62+
```python
63+
database = defaultdict(lambda: defaultdict())
64+
database["users"]["name"] = "ecmadao"
65+
```
66+
6067
### `fromkeys`
6168

6269
提供默认的值,通过一个list生成一个dict
@@ -138,7 +145,7 @@ dict_example = dict(ChainMap({}, info, default))
138145

139146
# method 5
140147
# 最优解
141-
dict_example = {**default, **info}
148+
dict_example = {**default, **info} # python 3.5以后版本支持
142149
```
143150

144151
### 命名元组
@@ -252,7 +259,7 @@ __slots__ = ['year', 'month', 'day']
252259
class Structure:
253260
_fields = []
254261

255-
def __init__(self, *args):
262+
def __init__(self, *args): # 缺点:参数定义不明确,不支持关键字参数
256263
if len(args) != len(self._fields):
257264
raise TypeError('Expected {} arguments'.format(len(self._fields)))
258265
# Set the arguments
@@ -276,7 +283,7 @@ class Stock(Structure):
276283
```python
277284
class Person:
278285
def __init__(self, name):
279-
self.name = _name
286+
self._name = name
280287
@property
281288
def name(self):
282289
return self._name
@@ -299,7 +306,7 @@ class Person:
299306
# 父类
300307
class Person:
301308
def __init__(self, name):
302-
self.name = name
309+
self._name = name
303310

304311
# Getter function
305312
@property
@@ -427,7 +434,7 @@ def is_number(s):
427434
```
428435

429436
```python
430-
# 对字符串对象用isdigit()方法:
437+
# 对字符串对象用isdigit()方法(只能检查是否是整数):
431438
a = "03523"
432439
a.isdigit()
433440
# True
@@ -499,4 +506,4 @@ b.isdigit()
499506
#### workflow
500507

501508
- [alfred-workflow](http://www.deanishe.net/alfred-workflow/)
502-
- [alfred-python](https://github.com/nikipore/alfred-python)
509+
- [alfred-python](https://github.com/nikipore/alfred-python)

Notes/译文/【译文】Material Design 新手?来瞅瞅你需要知道的12条原则.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Material Design现在变得很火了,许多设计师也不仅局限在Android
4747

4848
### 1.熟悉其核心思想
4949

50-
如果你想学Material Design,最好的开始方式就是去看[谷歌的官方文档]()
50+
如果你想学Material Design,最好的开始方式就是去看[谷歌的官方文档](https://material.io/design/introduction/)
5151

5252
文档会实时保持更新,并且解释说明了在使用Material Design设计过程中的一些细节。
5353

@@ -187,4 +187,4 @@ Material Design不易做到的原因之一是,有着如此之多繁重而又
187187

188188
而Material Design则就简单的多。但同时,也复杂的多。
189189

190-
最重要的一点:Material Design是一场有关细节的游戏。你需要更加务实专注的把设计转换为想要达到的目标,但同时,也不能太拟物。当你有疑问时,可以[来这里寻找灵感](https://www.behance.net/search?field=102&content=projects&sort=appreciations&time=week&search=material%20design)
190+
最重要的一点:Material Design是一场有关细节的游戏。你需要更加务实专注的把设计转换为想要达到的目标,但同时,也不能太拟物。当你有疑问时,可以[来这里寻找灵感](https://www.behance.net/search?field=102&content=projects&sort=appreciations&time=week&search=material%20design)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@
124124
### Python进阶
125125

126126
- [Magic Python](./Notes/Python/Python进阶/Magic%20Python.md)
127-
- [Effective Python](https://github.com/ecmadao/Coding-Guide/blob/master/Notes/Python/Python%E8%BF%9B%E9%98%B6/Effective%20Python.md)
127+
- [Effective Python](./Notes/Python/Python%E8%BF%9B%E9%98%B6/Effective%20Python.md)
128128
- [Python Style Guide](./Notes/Python/Python进阶/Python%20Style%20Guide.md)
129-
- [Python 中的 Collections 库](https://github.com/ecmadao/Coding-Guide/blob/master/Notes/Python/Python%E8%BF%9B%E9%98%B6/Python%20%E4%B8%AD%E7%9A%84%20Collections%20%E5%BA%93.md)
129+
- [Python 中的 Collections 库](./Notes/Python/Python%E8%BF%9B%E9%98%B6/Python%20%E4%B8%AD%E7%9A%84%20Collections%20%E5%BA%93.md)
130130

131131
### Ember文档翻译系列(V2.8.0)
132132

@@ -235,4 +235,4 @@
235235

236236
## License
237237

238-
Apache License 2.0
238+
Apache License 2.0

0 commit comments

Comments
 (0)