This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Jimbofbx
Recipients Jimbofbx, benjamin.peterson, eric.snow
Date 2011-12-29.21:28:41
SpamBayes Score 8.326673e-15
Marked as misclassified No
Message-id <1325194122.66.0.269945214609.issue13678@psf.upfronthosting.co.za>
In-reply-to
Content
For starters, this would be most efficient implementation:

def unique(varname, value, scope):
    assert(not varname in scope);
    scope[varname] = value;

Usage:
unique('b', 1, locals());
print(b);

But you can't put that in a loop else it will false trigger. Ideally this wouldn't false trigger. This could be done by having python internally associate a line number with each explicit variable declaration.

Anyways, an external python function would be too slow for my use case. Likewise, since it would be something you could use a lot, it should be implemented in the underlying C code to give it minimal overhead.

Keeping functions small is very impractical at times. I shouldn't create 50 randomly named one use functions in my class as a safeguard against accidental overwriting when I have a legitimately complicated piece of code that can't be dissected without becoming unreadable. In many cases I might need 8 or 9 locals at a time in a single line in each loop section.

I don't see how this is the area of pylint/pyflakes at all. The idea is to make it so the human doesn't have to carefully inspect their code in order to decide if they made a mistake or not. Inspecting a long list of warnings is no better, and arguably I could pull up a bunch of python language design decisions and ask why they were made if pylint/pyflakes exists.

If such a change would have be implemented after much consideration and discussion, I don't see how closing my post helps accomplish that.
History
Date User Action Args
2011-12-29 21:28:42Jimbofbxsetrecipients: + Jimbofbx, benjamin.peterson, eric.snow
2011-12-29 21:28:42Jimbofbxsetmessageid: <1325194122.66.0.269945214609.issue13678@psf.upfronthosting.co.za>
2011-12-29 21:28:42Jimbofbxlinkissue13678 messages
2011-12-29 21:28:41Jimbofbxcreate