[Tutor] Name spaces again
David Driver
count0.djd at gmail.com
Sun Apr 24 16:23:20 CEST 2005
I have read the essay at
<http://www.python.org/doc/essays/packages.html> and I am still having
problems understanding what I need to do. Here is the structure that I
am looking at:
Root folder
StartHere.py
Common folder
__init__.py
sobj.py
exceptions.py
validators.py
View folder (keeps cheetah and sxl templates)
Search folder (will be namespace for lookup operations)
Maintain folder (for creating and altering base domain objects)
Transact folder (namespace for creating transaction operations)
AR folder
__init__.py
sobj.py
exceptions.py
validators.py
View folder
Search folder
Maintain folder
Transact folder
AP folder
__init__.py
sobj.py
exceptions.py
validators.py
View folder
Search folder
Maintain folder
Transact folder
GL folder
__init__.py
sobj.py
exceptions.py
validators.py
View folder
Search folder
Maintain folder
Transact folder
StartHere.py contains:
import Common
import AR
import AP
Each subpackage __init__.py contains:
import exceptions
import validators
import sobjs
import Maintain
import Transact
import Search
import View
In AR.sobjs I have a class that is inherited from
Common.sobjs.baseDomObj. When I run StartHere.py Common imports just
fine. It starts to import AR and AR. __init__.py imports AR.sobjs.py
and it throws the following error:
Traceback (most recent call last):
File "C:\foo\doinit\starthere.py", line 3, in ?
import AR
File "C:\foo\doinit\AR\__init__.py", line 3, in ?
import sobjs
File "C:\foo\doinit\AR\sobjs.py", line 1, in ?
class custAddress(Common.address):
NameError: name 'Common' is not defined
Do I need to import Common in each sub package to have access to it?
Does it consume more memory? What about Sub Sub packages? shouldn't
you be able to Import DateTime in StartHere and have all sub
modules/packages that are imported into StartHere.py use it? Am I
making a big deal out of nothing?
This entire project is more or less of a mock up of a project. I am
just trying to learn more about python and I am basing it on the VB
based accounting package I currently maintain. It isn't that I would
normally organize an app this way if I were building a new one.
--
***********************************
See there, that wasn't so bad.
***********************************
More information about the Tutor
mailing list