Skip to content

Commit 7c32897

Browse files
author
Silverhand Miles
authored
Merge branch 'yidao620c:master' into master
2 parents 9fceb3d + a9cd77b commit 7c32897

File tree

324 files changed

+102342
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

324 files changed

+102342
-93
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[![Github downloads](https://img.shields.io/github/downloads/yidao620c/python3-cookbook/total.svg)](https://github.com/yidao620c/python3-cookbook/releases/latest)
55
[![GitHub release](https://img.shields.io/github/release/yidao620c/python3-cookbook.svg)](https://github.com/yidao620c/python3-cookbook/releases)
66

7-
87
# 《Python Cookbook》 3rd Edition 翻译
98

109
《Python Cookbook》3rd 中文版3.0.0正式发布啦 ^_^! ——2017/12/07
@@ -16,6 +15,16 @@
1615
* 中文简体版PDF下载地址:<https://pan.baidu.com/s/1pL1cI9d>
1716
* 中文繁体版PDF下载地址:<https://pan.baidu.com/s/1qX97VJI>
1817

18+
## 关于作者David Beazley
19+
20+
本书作者是David Beazley大神,一位独立的计算机科学家、教育家,以及有着35年开发经验的软件开发者。
21+
他在Python社区一直都很活跃,编写了很多的[python包](http://www.dabeaz.com/software.html)
22+
发表了很多的公开[演讲视频](http://www.dabeaz.com/talks.html) 以及
23+
[编程教程](http://www.dabeaz.com/tutorials.html)
24+
同时还是[Python Essential Reference](http://www.dabeaz.com/per.html) 以及
25+
[ Python Cookbook (O'Reilly Media)](http://www.dabeaz.com/cookbook.html)的作者。
26+
27+
David Beazley大神的博客地址:<http://www.dabeaz.com/>
1928

2029
## 译者的话
2130

@@ -34,7 +43,9 @@
3443

3544
目前已经正式完成了整本书的翻译工作,历时2年,不管怎样还是坚持下来了。现在共享给python社区。
3645

37-
**捐助渠道已开通,如有意向请点击[【微信二维码】](qcode.jpg) 捐赠。**
46+
**欢迎关注我的个人公众号“飞污熊”,我会定期分享一些自己的Python学习笔记和心得。**
47+
48+
![公众号](https://github.com/yidao620c/python3-cookbook/raw/master/exts/wuxiong.jpg)
3849

3950

4051
## 项目说明
@@ -57,7 +68,6 @@ if not on_rtd: # only import and set the theme if we're building docs locally
5768
# otherwise, readthedocs.org uses their theme by default, so no need to specify it
5869
```
5970

60-
6171
## 其他贡献者
6272

6373
排名不分先后:

README_en.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
2+
[![GitHub issues](https://img.shields.io/github/issues/yidao620c/python3-cookbook.svg)](https://github.com/yidao620c/python3-cookbook/issues)
3+
[![License][licensesvg]][license]
4+
[![Github downloads](https://img.shields.io/github/downloads/yidao620c/python3-cookbook/total.svg)](https://github.com/yidao620c/python3-cookbook/releases/latest)
5+
[![GitHub release](https://img.shields.io/github/release/yidao620c/python3-cookbook.svg)](https://github.com/yidao620c/python3-cookbook/releases)
6+
7+
Online reading address: http://python3-cookbook.readthedocs.org/zh_CN/latest/
8+
9+
The latest version (3.0.0) download
10+
11+
* Chinese simplified version PDF download address: https://pan.baidu.com/s/1pL1cI9d
12+
* Chinese Traditional Chinese PDF download address: https://pan.baidu.com/s/1qX97VJI
13+
14+
## Translator's words
15+
16+
Life is short, I use Python!
17+
18+
The translator has always insisted on using Python 3 because it represents the future of Python. Although backward compatibility is its flaw, this situation will change sooner or later, and the future of Python3 needs everyone's help and support. At present, the tutorial books on the market, most of the manuals on the Internet are basically 2.x series, and the books based on the 3.x series are less pitiful.
19+
20+
Life is short, I use Python!
21+
22+
The translator has always insisted on using Python 3 because it represents the future of Python. Although backward compatibility is its hard injury, this situation will change sooner or later,
23+
And the future of Python 3 needs everyone's help and support.
24+
At present, the tutorial books on the market, most of the manuals on the Internet are basically 2.x series, and the books based on the 3.x series are less pitiful.
25+
26+
I recently saw a Python Cookbook 3rd Edition, based entirely on Python3, which is also very good.
27+
For the popularity of Python3, I am not self-sufficient and want to do something. Ever since, there is an impulse to translate this book!
28+
This is not an easy job, but it is a worthwhile job: it is not only convenient for others, but also an exercise and improvement for your ability to translate.
29+
30+
The translator will insist on being responsible for the translation of each sentence and strive for high quality. However, due to limited ability, it is inevitable that there will be omissions or improper expressions.
31+
If there is anything wrong with the translation, please forgive me and welcome everyone to correct me.
32+
33+
At present, the translation of the entire book has been officially completed. It lasted for 2 years, and it persisted anyway. Now share it with the python community.
34+
35+
**Welcome to my personal public number "Flying Saffron Bear", I will share some of my own Python study notes and tips on a regular basis. **
36+
37+
38+
[[Public Number] (https://github.com/yidao620c/python3-cookbook/raw/master/exts/wuxiong.jpg)
39+
40+
41+
## project instruction
42+
43+
* All documents are edited using reStructuredText, refer to [reStructuredText] (http://docutils.sourceforge.net/docs/user/rst/quickref.html)
44+
* Current document generation is hosted on [readthedocs] (https://readthedocs.org/)
45+
* Generated document preview address: [python3-cookbook](http://python3-cookbook.readthedocs.org/zh_CN/latest/)
46+
* Use the python official documentation theme [sphinx-rtd-theme] (https://github.com/snide/sphinx_rtd_theme), which is also the default theme default.
47+
* All code in the book runs under Python 3.6, all source code is placed under the cookbook package
48+
```
49+
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
50+
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
51+
52+
if not on_rtd: # only import and set the theme if we're building docs locally
53+
import sphinx_rtd_theme
54+
html_theme = 'sphinx_rtd_theme'
55+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
56+
57+
# otherwise, readthedocs.org uses their theme by default, so no need to specify it
58+
```
59+
60+
## Other contributors
61+
62+
names not listed in order:
63+
64+
1. Yu Longjun (https://github.com/yulongjun)
65+
1. tylinux (https://github.com/tylinux)
66+
1. Kevin Guan (https://github.com/K-Guan)
67+
1. littlezz (https://github.com/littlezz)
68+
1. cclauss (https://github.com/cclauss)
69+
1. Yan Zhang (https://github.com/Eskibear)
70+
1. xiuyanduan (https://github.com/xiuyanduan)
71+
1. FPlust (https://github.com/fplust)
72+
1. lambdaplus (https://github.com/lambdaplus)
73+
1. Tony Yang ([email protected])
74+
75+
76+
[More contributors] (https://github.com/yidao620c/python3-cookbook/graphs/contributors)
77+
78+
-------------------------------------------------- ---
79+
80+
## About source code generation PDF file
81+
82+
Some netizens asked how to generate a PDF file from the source code. Since this step is a bit long, it is not suitable for being placed in the README.
83+
I wrote a blog dedicated to how to use the ReadtheDocs to host documents, how to generate PDF files yourself, you can refer to it.
84+
85+
<https://www.xncoding.com/2017/01/22/fullstack/readthedoc.html>
86+
87+
In addition, the issue of the title number is automatically generated in the generated PDF file, and the enthusiastic user [CarlKing5019] (https://github.com/CarlKing5019) proposes a solution.
88+
Please refer to issues108:
89+
90+
<https://github.com/yidao620c/python3-cookbook/issues/108>
91+
92+
Thanks again to each contributor.
93+
94+
-----------------------------------------------------
95+
96+
## How to Contribute
97+
98+
You are welcome to contribute to the project as follow
99+
100+
* fork project and commit pull requests
101+
* add/edit wiki
102+
* report/fix issue
103+
* code review
104+
* commit new feature
105+
* add testcase
106+
107+
Meanwhile you'd better follow the rules below
108+
109+
* It's *NOT* recommended to submit a pull request directly to `master` branch. `develop` branch is more appropriate
110+
* Follow common Python coding conventions
111+
* Add the following [license] in each source file
112+
113+
## License
114+
115+
(The Apache License)
116+
117+
Copyright (c) 2014-2018 [Xiong Neng](<https://www.xncoding.com/>) and other contributors
118+
119+
Licensed under the Apache License, Version 2.0 (the "License");
120+
you may not use this file except in compliance with the License. You may obtain a copy of the License at
121+
122+
http://www.apache.org/licenses/LICENSE-2.0
123+
124+
Unless required by applicable law or agreed to in writing,
125+
software distributed under the License is distributed on an "AS IS" BASIS,
126+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127+
See the License for the specific language governing permissions and limitations under the License.
128+
129+
130+
[licensesvg]: https://img.shields.io/hexpm/l/plug.svg
131+
[license]: http://www.apache.org/licenses/LICENSE-2.0

cookbook/c02/p05_search_replace.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def search_replace():
2020
# 复杂的模式,使用sub()
2121
text = 'Today is 11/27/2012. PyCon starts 3/13/2013.'
2222
print(re.sub(r'(\d+)/(\d+)/(\d+)', r'\3-\1-\2', text))
23+
print(re.sub(r'(?P<month>\d+)/(?P<day>\d+)/(?P<year>\d+)', r'\g<year>-\g<month>-\g<day>', text))
2324

2425
# 先编译
2526
datepat = re.compile(r'(\d+)/(\d+)/(\d+)')

cookbook/c04/p08_skip_iterable.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
def skip_iter():
1212
# with open('/etc/passwd') as f:
13-
# for line in dropwhile(lambda line: line.startswith('#'), f):
13+
# for line in dropwhile(lambda line: not line.startswith('#'), f):
1414
# print(line, end='')
1515

16-
# 明确知道了要跳过的元素个数
16+
# 明确知道了要跳过的元素序号
1717
items = ['a', 'b', 'c', 1, 4, 10, 15]
18-
for x in islice(items, None, 3):
18+
for x in islice(items, 3, None):
1919
print(x)
2020

2121
if __name__ == '__main__':

cookbook/c08/p25_cached_objects.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- encoding: utf-8 -*-
33
"""
44
Topic: 创建缓存实例
5-
Desc :
5+
Desc :
66
"""
77

88
import logging
@@ -78,8 +78,8 @@ class Spam2:
7878
def __init__(self, name):
7979
self.name = name
8080

81-
def get_spam(name):
82-
return Spam2.manager.get_spam(name)
81+
def get_spam(name):
82+
return Spam2.manager.get_spam(name)
8383

8484

8585
# ------------------------最后的修正方案------------------------
@@ -114,4 +114,4 @@ def _new(cls, name):
114114
cachedSpamManager = CachedSpamManager2()
115115
s = cachedSpamManager.get_spam('Dave')
116116
t = cachedSpamManager.get_spam('Dave')
117-
print(s is t)
117+
print(s is t)

exts/wuxiong.jpg

7.77 KB
Loading

0 commit comments

Comments
 (0)