Nested scopes hitch

Donn Cave donn at drizzle.com
Tue Apr 9 02:02:47 EDT 2002


Quoth Jeff Shannon <jeff at ccvcorp.com>:
...
| I obviously can't speak to your specific designs, not having seen 
| them, but I can't imagine how globals()/locals() would be 
| necessary unless you have a large amount of interdependencies in 
| your code, and it is generally accepted that interdependent code 
| is not a good thing.  If you can explain to me how you can 
| require access to large portions of another scope's namespace 
| without having large interdependencies, then perhaps I'll change 
| my mind about this method.

I use it during class definition, to add a set of shadow functions.
In a class definition, the methods etc. are in locals().  I compute
further methods by looking at the existing methods, so I must pass
locals() to the function that does that.

You don't have to love the idea, but if there's anything horrifying
about, it's not that I'm passing locals() to a function.

	Donn Cave, donn at drizzle.com



More information about the Python-list mailing list