[Edu-sig] import mechanism questions
Arthur
Arthur" <ajs@ix.netcom.com
Sun, 12 Jan 2003 22:07:30 -0500
> Are you fully exploiting the 'package' feature by using
> the top level __init__.py in /PyGeo to bring in everything
> a user might need?
Inbetween drivng my son to the airport to go back to college, exactly what
I'm up to. And making good progress.
Before:
a typical PyGeo construction might have required:
from VPyFrame import VPyGeo
from Complex import *
from GeoConstants import *
from utils.utils import randomXYZ
to get started.
Got that down to:
from PyGeo.PyElements import *
from PyGeo import randomXYZ
using the mechanisms of __init__.py imports
My post was just me getting greedy, and trying to get PyGeo.PyElements down
to PyElements
> >>> sys.modules['Complex'] = Geometry.Complex
I think this is good!
putting:
import sys
import PyGeo.Complex
import PyGeo.Real
sys.modules['Complex'] = PyGeo.Complex
sys.modules['Real']=PyGeo.Real
in the __init__.py of the toplevel directory
I can have all scripts start with:
from PyGeo import * (this will bring in all utilities functions, including,
e.g. randomXYZ)
and then one of
from Complex import *
or
from Real import *
depending on the mode one wants to work in.
And that should be it.
Which I think is just fine, actually.
And so far I don't see a catch.
You're scary sometimes Urner.
Thanks.
Art