Scope: Simple and explicit better than nested?

rturpin at my-deja.com rturpin at my-deja.com
Tue Feb 6 18:10:47 EST 2001


The recent discussions of nested scope have convinced me that
this is the wrong and unpythonic solution to newbies confused
by global, local, and builtin namespaces. Instead of making
name resolution more complex and more implicit, just to give
people something familiar, let's solve the problem by
requiring everything to be explicit. Let's do away with both
global and builtin namespaces. There is only one namespace,
and it is the local namespace. Both "builtin" and the
containing module (if any) are automatically entered into it.
But to get to THEIR objects would require EXPLICIT scoping:

    if (builtin.callable(foo)):
        my_module.doSomething(foo)

The only unscoped names would be local variables and
parameters. Period, full stop. That should be easy to
understand, even for Pascal and SmallTalk programmers.

Along with this change, we should eliminate the "from"
statement. Names inside modules would be explicitly scoped.
Always. Simple and explicit. That is the pythonic way to go.

Hating-name-space-rules-ly yrs,
Russell


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list