[wingide-users] Syntax highlighting for builtins?
fuzzyman at voidspace.org.uk
Fri Jul 11 15:07:14 MDT 2008
Wingware Support wrote:
> Mike Driscoll wrote:
>> Are there any plans to add support for builtins then? Or is there a
>> plug-in that does this that some clever individual has created? I've
>> noticed this with other Python IDE's too and wondered why IDLE seems
>> to be the only popular one that includes builtin hightlighting. I
>> can't be the only one who cares about accidentally shadowing a builtin.
> It's not been requested before, as far as I know, so isn't in our
> plans yet.
> If you do shadow a builtin, it really doesn't matter unless you need
> to use the
> builtin in the same scope. In that case it's probably fairly obvious
> going on. For example, you could goto-definition on the name and Wing
> go to your shadow's point of definition.
It isn't always obvious and it is an issue I have seen others encounter.
Consider the following code inside the body of a method.
for i in range(x):
.... more code
range = GetRange()
When executed, the *first* use of range blows up with an
'UnboundLocalError', since range is now an unbound local variable rather
than a builtin. As the exception doesn't occur at the point of the
problem it can be confusing if you don't know what is going on.
FWIW, detecting builtin shadowing is one of the things we use PyLint for.
> For what it's worth, this is just not an issue I've run into in 10+ years
> of intensive Python programming and I'll be the first to admit that I
> don't really know what all the builtins are by name. I know I do
> shadow len,
> dir, file, and id fairly often and also I suspect hash, quit, and a
> few others
> as well. The only one I've started to stay away from instinctively is
> Anyway, I suspect others have similar experiences and it's the reason the
> IDEs don't have this. IDLE may have it since it had somewhat of a
> focus early on.
More information about the wingide-users