Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修正不正确的缩进,保持与原版的代码逻辑一致 #201

Merged
merged 2 commits into from
Nov 30, 2017

Conversation

jeremyxu2010
Copy link
Contributor

@jeremyxu2010 jeremyxu2010 commented Oct 4, 2017

  1. 修正不正确的缩进,保持与原版的代码逻辑一致。原版代码见https://github.com/dabeaz/python-cookbook/blob/master/src/2/combining_and_concatenating_strings/example.py
  2. 修改为更准确的描述,itertools.chain(*files)导致gen_opener()生成器被提前全部消费掉,因此在此场景不适合,参见原文https://www.safaribooksonline.com/library/view/python-cookbook-3rd/9781449357337/ch04s13.html。但仍可以用yield from itertools.chain.from_iterable(files),itertools.chain.from_iterable相对于itertools.chain,它是懒消费的。
    https://stackoverflow.com/questions/15004772/what-is-the-difference-between-chain-and-chain-from-iterable-in-itertools。

itertools.chain(*files)导致gen_opener()生成器被提前全部消费掉,因此在此场景不适合,参见原文https://www.safaribooksonline.com/library/view/python-cookbook-3rd/9781449357337/ch04s13.html。但仍可以用yield from itertools.chain.from_iterable(files),itertools.chain.from_iterable相对于itertools.chain,它是懒消费的。
见https://stackoverflow.com/questions/15004772/what-is-the-difference-between-chain-and-chain-from-iterable-in-itertools。
@yidao620c yidao620c merged commit 506d436 into yidao620c:master Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants