Steven D'Aprano wrote:
On Fri, 20 Nov 2009 08:02:38 -0800, Ethan Furman wrote:
module scope == global scope
That is, there is nothing higher than module scope. (So, yes, global is
a slight misnomer... in Python it means 'global to a module'.)
Actually there is: built-ins.
That's why you can access (e.g.) len without having to define it, or
import it, first. And what's more, you can do this:
len([1,2,3])
3
def len(x): # Shadow the built-in
... return -3
...
len([1,2,3])
-3
del len
len([1,2,3]) # It's back!
3
Very good point, I had forgotten. Of course, injecting into built-ins
is not recommended.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list