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

第2篇好像有个bug #32

Closed
SoftDoggy opened this issue Aug 26, 2019 · 3 comments
Closed

第2篇好像有个bug #32

SoftDoggy opened this issue Aug 26, 2019 · 3 comments

Comments

@SoftDoggy
Copy link

https://github.com/piglei/one-python-craftsman/blob/master/zh_CN/2-if-else-block-secrets.md
第二篇里面的第四节,使用 try/while/for 中 else 分支,第一段函数里面,抛出异常的话应该就直接return了,怎么样都不会运行到do_the_second_thing()了吧。

@piglei
Copy link
Owner

piglei commented Aug 27, 2019

do_the_second_thing() 应该是在未抛出异常时执行,不是抛出异常的时候。

@SoftDoggy
Copy link
Author

既然只有未抛出异常的时候才会执行下去,为什么还要判断if first_thing_successed呢

@piglei
Copy link
Owner

piglei commented Aug 27, 2019

在这段代码里面,确实是这样。😂
我觉得这段代码只适合作为 demo 理解,如果调整一下 except 里的逻辑可能会更好一些。

@piglei piglei closed this as completed Aug 27, 2019
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

No branches or pull requests

2 participants