> Question: In the absence of a
> from something import *
> statement, are there other cases where Python cannot (in principle, & at
> compile time) tell whether the name 'range' denotes the built-in? This
> is the tip of a much broader question, relevant a few years down the
> road, when Python has taken over much of the world & I'll be thinking of
> making a living by selling an optimizing Python compiler <smile>.
Actually, since built-in names come after module-global names, it is
always possible to sabotage a module by doing something like
return range(1, n+1)
foobar.range = sick_range
Depending upon the use that foobar.innocent_function() makes of
range() this could have no effect, a benign effect, a humorous effect,
or a disastrous effect...
A global scan of all modules might prove that there is no redefinition
of 'range' anywhere, but a single use of exec or even setattr may make
everything uncertain again...
--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>