[Python-Dev] capability-mediated modules

Phillip J. Eby pje@telecommunity.com
Tue, 18 Mar 2003 12:41:01 -0500


Zooko wrote:
 >Just to help me think about it I'll suggest a non-Pythonic and 
incompatible way:
 >there is no "import" keyword.  When you invoke a constructor, function, 
method,
 >etc., you have to pass as arguments references to everything that the 
code will
 >need to do its job.  So, assuming the tic-tac-toe game requires the "math"
 >module and the "string" module, I would have to write:

There's a *much* simpler way to do this.  'import' is implemented by 
calling an '__import__' function -- which of course is a capability.  To do 
mediated imports, it's only necessary to supply a mediating version of 
'__import__'.  One also needs a specialized version of '__import__' to set 
up a newly imported module's builtins.