nested scopes
Geoffrey Gerrietts
geoff at homegain.com
Fri Feb 2 21:38:54 EST 2001
Jeremy writes:
> I don't understand your complaint. The first part I follow: You don't
> want to import names into the module scope. Then you say
> that explicit
> imports will cause you to pursue changes over the whole
> world. I don't
> get that.
I think that part of your confusion might be based on your conception
of what a module is for. The premise upon which you base your argument
is that you will not be using the names you acquire in a dynamic way.
For example, if I have a large file, or a large collection of files,
all of which contain a large number of variable definitions, I can suck
those up into a function and use dir() to grab the list and do things
with them.
Harder now, without polluting your global namespace, but you can presumably
load all the names into a local dictionary, assuming __import__ will not
restrict us.
An alternative situation where this might be used is in fact highlighted
by the very case that the limitation allowed 2.1 to ignore; if we are
trying to exploit the dynamism of the language by executing one piece of
code
while changing out the names it imports from underneath it.
While I can't say I don't find nested scopes interesting, I confess that
I find them just as troublesome, and I'm really kinda sad to see dynamic
features yanked from the language (even if they're unintentional features)
just so we can have nested scoping.
---
Geoff Gerrietts <geoff at homegain.com>
More information about the Python-list
mailing list