-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Delete module-level loop variables when no longer needed #90723
Comments
Some variables created as I wrote a simple Here's what I got:
I think, that we need to remove these names. Why?
I think that adding
PR is on its way! |
+1 for the proposed PR. Loop variables leaking into the global namespace creates an extra burden for typeshed when we have to wade through a long list of objects that our tests report are present at runtime but not in the typeshed stubs. It's not the end of the world, but it takes time, and is annoying. As Nikita explains, these leaky variables also make the output of The fix isn't hard, and shouldn't, in my opinion, be particularly controversial. |
I am opposed at this time. Leaving loop variables available is an intended feature of python. After reading point 1, I was tempted to say that you are making a fetish of typing or making the tail wag the dog. I mention this because others might have similar reactions. After reading points 2 and 3, I am much more favorable and would allow changes in idlelib if any were needed. A cleaner dir and help listing affects everyone. I changed the title to be more 'neutral'. 'Leak' is perjorative. "we need to remove these names" is a bit misleading as it implies total removal, which is not the proposal. As it is, the PR applies a style standard on the stdlib that is not in PEP-8. I recommend that you start by proposing an addition to PEP-8. If you do, I recommend starting with dir and help, with typing third. You might post the idea on pydev and ask how much and what sort of discussion is needed. |
for
loop variables into module's namespace
Thanks for the better wording, Terry!
Just to be clear: it sure is! But, sometimes we don't want to polute a global namespace with this variable. A common practice across CPython's source is to use
Interesting idea! But, I think that this is an orthogonal non-blocking task, which might be much harder compared to this one :) I will add this to my backlog.
Good starting point, agreed! |
I agree that the typeshed issue is less important than the output of dir() and help(). I also agree that we shouldn't make a fetish of typing. However, I see the typeshed issue less as an issue specific to typing, and more as an example that illustrates a general problem third-party tools have. For example, having these temporary variables leak into global namespaces also makes IDE autocompletion less valuable, and makes life harder for tools that auto-generate documentation. Perhaps a PEP-8 revision might be warranted in due course — but in the meantime, are there any downsides to this proposed change? I believe we have pointed out several upsides. I don't see this as a style issue first and foremost: the PR is attempting to solve a genuine problem for some end-users of Python. It is not simply making cosmetic changes. |
del
loop vars that are leaking into module namespaces #30993Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: