On Sun, May 13, 2018 at 10:53:50AM +1000, Cameron Simpson wrote:
For myself, I'm not a fan of a narrow scope. I'd be happy with an inline assignment landing in the function scope (or whatever the current innermost scope is). Like normal assignments. In how many other places does Python adopt a narrower scope than the function/method/class/module?
None except for comprehensions and generators. And may it stay that way :-)
I'm going to digress into an explaination of this issue in Go here because I want to highlight my dislike of easy accidental shadowing, which is a problem in many areas, and I think that conflating inline assignment with an implied narrow scope in Python would make this worse. [...]
Thanks Cameron! This is a really good practical example of why narrow scopes should be avoided. -- Steve