[Python-Dev] capability-mediated modules (was: python-dev Summary for 2003-03-01 through 2003-03-15)

Greg Ewing greg@cosc.canterbury.ac.nz
Wed, 19 Mar 2003 11:17:55 +1200 (NZST)


Zooko <zooko@zooko.com>:

> Now what I would *like* is that instead of doing "import os" to load code, 
> instead the caller provides, or doesn't provide the os module as part of the 
> construction/invocation of A.
> 
> I don't have a clear idea yet of how that could be implemented in a 
> Pythonic, compatible way.

Maybe, instead of there being one ultra-global namespace for importing
modules from, it should be part of a function's environment. By
default a function invocation would inherit the "import environment"
of it's caller, but the caller could override this to provide a more
restricted environment.

This would be equivalent to passing in a set of allowable
modules as an implicit parameter to every call.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+