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

为什么列表解析式设计出独立作用域? #6

Open
chinesehuazhou opened this issue Dec 13, 2022 · 0 comments
Open

为什么列表解析式设计出独立作用域? #6

chinesehuazhou opened this issue Dec 13, 2022 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@chinesehuazhou
Copy link
Owner

chinesehuazhou commented Dec 13, 2022

问题灵感:
@古明地觉https://mp.weixin.qq.com/s/fPmo14sBZXJgEUodTL7y1g

Python 在变量查找的时候遵循 LEGB 规则,也就是按照本地作用域、闭包、全局作用域、内置作用域的顺序。然而,列表解析式有自己的本地作用域,并不使用函数或者类的作用域!!

1.为什么py3会这样?
2.为什么py3和py2的行为不一样?

@chinesehuazhou chinesehuazhou added help wanted Extra attention is needed good first issue Good for newcomers labels Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant