[issue13678] way to prevent accidental variable overriding

2011-12-29 Thread Benjamin Peterson
Benjamin Peterson added the comment: I suggest you mail python-ideas. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Uns

[issue13678] way to prevent accidental variable overriding

2011-12-29 Thread James Hutchison
James Hutchison 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

[issue13678] way to prevent accidental variable overriding

2011-12-29 Thread Benjamin Peterson
Benjamin Peterson added the comment: I think this more the domain of pylint/pyflakes. -- nosy: +benjamin.peterson resolution: -> rejected status: open -> closed ___ Python tracker

[issue13678] way to prevent accidental variable overriding

2011-12-29 Thread Eric Snow
Eric Snow added the comment: Interesting thought, the syntax seems unnecessary. Adding new syntax to the language is something that happens rarely and only with a _lot_ of consideration. As a slightly more verbose alternative, currently you can do this: def fail_if_defined(*args, namespa

[issue13678] way to prevent accidental variable overriding

2011-12-29 Thread James Hutchison
New submission from James Hutchison : In python is currently there a way to elegantly throw an error if a variable is already in the current scope? For example: def longfunc(self, filename): FILE = open(filename); header = FILE.readline(); ... bunch of code ... childfiles = sel