import and package confusion

Scott David Daniels Scott.Daniels at Acm.Org
Wed Apr 29 22:12:33 CEST 2009


Dale Amon wrote:
> I am trying to get to the heart of what it is I am
> missing. Is it the case that if you have a module C in a 
> package A:
> 	A.C
> that there is no way to load it such that you can use:
> 	x = A.C()
> in your code? 
OK, here's a simple question.  What do you expect from:
    import sys
    sys()
sys is a module, and as such, it is not callable.
Just because you put a class inside a module, does not mean
that class magically does something by virtue of having the
same name as the module.

A module is a namespace to hold classes, functions, etc....
A package is a namespace to hold modules (possibly more).

I don't understand why you don't use files like:

	VLMLegacy/
          __init__.py
          Reader.py
          VLM4997.py
          WINGTL.py
But, presuming some kind of rationale,
put the code you want in 
	VLMLegacy/VLM4997/__init__.py

--Scott David Daniels
Scott.Daniels at Acm.Org


--Scott David Daniels
Scott.Daniels at Acm.Org




More information about the Python-list mailing list