James Hutchison <jamesghutchi...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13678>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to