[PYTHON MATRIX-SIG] package, ni, and Numeric
Jim Phillips
jim@ks.uiuc.edu
Wed, 23 Oct 96 15:33:42 -0500
Hi,
After Numeric's brief interlude with packages and ni, I have to agree that ni
is not ready for prime time. At the very least, packages should be a
mandatory extension to the import methods, not an extra import that changes
system functionality for everything.
Anyway, I now notice that Numeric is fundamentally incompatible with ni
because it usually resides in a subdirectory of a valid path with the same
name as the module. Thus, when ni is imported, it attempts to import Numeric
as a package and bombs on "from Numeric import *". This is the kind of cross
module incompatibility that is just plain bad. See the dump below for a
disturbing example.
An OK fix would probably be to revise ni to always attempt to import
something as a module before importing it as a package, or at the very least
to make sure the package directory isn't also part of the path. The best
solution would be to make the package status of a directory explicit by
requiring a special extension, such as the usual .py (the interpreter can tell
the difference between a directory and a file, right?).
As a workaround, one could change the Numeric directory name to numeric.
-Jim Phillips
jim@ks.uiuc.edu
jim@paris(54) python
Python 1.4b3 (Tue Oct 22 1996) [GCC NeXT DevKit-based CPP 3.1]
Copyright 1991-1996 Stichting Mathematisch Centrum, Amsterdam
>>> import Matrix, ni
>>> ^D
jim@paris(55) python
Python 1.4b3 (Tue Oct 22 1996) [GCC NeXT DevKit-based CPP 3.1]
Copyright 1991-1996 Stichting Mathematisch Centrum, Amsterdam
>>> import ni, Matrix
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "/usr/local/shared/lib/python1.4/ni.py", line 302, in import_module
m = self.get0(mname)
File "/usr/local/shared/lib/python1.4/ni.py", line 344, in get0
m = self.get(name)
File "/usr/local/shared/lib/python1.4/ni.py", line 362, in get
sys.modules[name] = m = self.loader.load_module(name, stuff)
File "/usr/local/shared/lib/python1.4/ni.py", line 204, in load_module
return ModuleLoader.load_module(self, name, stuff)
File "/usr/local/shared/lib/python1.4/ihooks.py", line 259, in load_module
return self.hooks.load_source(name, filename, file)
File "/usr/local/shared/lib/python1.4/ihooks.py", line 170, in load_source
return imp.load_source(name, filename, file)
File "/usr/local/shared/lib/python1.4/Numeric/Matrix.py", line 2, in ?
from Numeric import dot
File "/usr/local/shared/lib/python1.4/ni.py", line 306, in import_module
return self.finish(m, m, tail, fromlist)
File "/usr/local/shared/lib/python1.4/ni.py", line 334, in finish
self.get1(fname)
File "/usr/local/shared/lib/python1.4/ni.py", line 340, in get1
raise ImportError, "No module named %s" % name
ImportError: No module named Numeric.dot
>>> ^D
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================