[Edu-sig] import mechanism questions

Arthur Arthur" <ajs@ix.netcom.com
Sun, 12 Jan 2003 20:13:17 -0500


(this belongs on tutor, but since the investigation that led me her2 started
from edu-sig discussion I am copying there)


To setup, I have a directory called "Geometry", with 2 modules "Real" and
"Complex".

>From the command line:

Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help

>>> import Geometry
>>> Complex=Geometry.Complex
>>> Complex

<module 'Geometry.Complex' from
'C:\Python22\lib\site-packages\Geometry\Complex.pyc'>

>>> from Complex import *

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in ?
    from Complex import *
ImportError: No module named Complex

>>> from PyGeo.Complex import *
>>>

My Python instincts are a little surprised by this.  In my mind Complex and
Geometry.Complex have become identical by the
Complex=Geometry.Complex line

but obviously the import mechanism is  not working from "names" in the same
way "names" are usually used in scripts.

In the end what I am trying to accomplish is simplification of importing for
the users of my modules

instead of

from Geometry.Complex import *
or
from Geometry.Real import *

I would ideally like the following to be sufficient (not a real big deal,
one way or other, admittedly):

from Complex import *
or
from Real import *

Ideas appreciated.

Art