Skip to content

Commit

Permalink
update from issue
Browse files Browse the repository at this point in the history
  • Loading branch information
iswbm committed Apr 14, 2021
1 parent d67af1c commit d8b2265
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion source/c01/c01_15.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

当你执行 `env python` 时,它其实会去 `env | grep PATH` 里(也就是 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin )这几个路径里去依次查找名为python的可执行文件。

找到一个就直接执行,上面我们的 python 路径是在 `/usr/bin/python` 里,在 `PATH` 列表里倒数第二个目录下,所以当我在 `/usr/local/sbin` 下创建一个名字也为 python 的可执行文件时,就会执行 `/usr/bin/python` 了。
找到一个就直接执行,上面我们的 python 路径是在 `/usr/bin/python` 里,在 `PATH` 列表里倒数第二个目录下,所以当我在 `/usr/local/sbin` 下创建一个名字也为 python 的可执行文件时,就会执行 `/usr/local/sbin/python` 了。

具体演示过程,你可以看下面。

Expand Down
4 changes: 2 additions & 2 deletions source/c01/c01_15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@

找到一个就直接执行,上面我们的 python 路径是在 ``/usr/bin/python``
里,在 ``PATH`` 列表里倒数第二个目录下,所以当我在 ``/usr/local/sbin``
下创建一个名字也为 python 的可执行文件时,就会执行 ``/usr/bin/python``
了。
下创建一个名字也为 python 的可执行文件时,就会执行
``/usr/local/sbin/python`` 了。

具体演示过程,你可以看下面。

Expand Down
9 changes: 9 additions & 0 deletions source/c05/c05_06.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ def read_from_file(filename, block_size = 1024 * 8):
yield chunk
```

如果你使用的是 Python 3.8 +,还有一种更直观、易于理解的写法,既不用使用偏函数,也不用掌握 iter 这种另类的用法。而只要用利用 海象运算符就可以,具体代码如下

```python
def read_from_file(filename, block_size = 1024 * 8):
with open(filename, "r") as fp:
while chunk := fp.read(block_size):
yield chunk
```



![](http://image.iswbm.com/20200607174235.png)
11 changes: 11 additions & 0 deletions source/c05/c05_06.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@
for chunk in iter(partial(fp.read, block_size), ""):
yield chunk
如果你使用的是 Python 3.8
+,还有一种更直观、易于理解的写法,既不用使用偏函数,也不用掌握 iter
这种另类的用法。而只要用利用 海象运算符就可以,具体代码如下

.. code:: python
def read_from_file(filename, block_size = 1024 * 8):
with open(filename, "r") as fp:
while chunk := fp.read(block_size):
yield chunk
|image1|

.. |image0| image:: http://image.iswbm.com/20200804124133.png
Expand Down

0 comments on commit d8b2265

Please sign in to comment.