Cross-reference 'import' in a class hierarchy

Jp Calderone exarkun at intarweb.us
Tue Apr 8 01:12:55 EDT 2003


On Tue, Apr 08, 2003 at 04:55:09AM +0000, Ben Finney wrote:
> On Tue, 08 Apr 2003 15:44:10 +1200, Greg Ewing (using news.cis.dfn.de) wrote:
> > It's been suggested before (and I happen to agree) that Python should
> > provide a general way of making *relative* references to modules or
> > packages.
> 
> I continue to be amazed that there's simply no way to say
> 
>   import "../foo/ook.py"
> 
> as should be possible to implement any well-architected class hierarchy.

  It's simple.  Code should not depend directly on code higher than it in
the package hierarchy.  If it does (and it isn't one of a few extremely rare
cases), it is misdesigned.

  Code shallow in the hierarchy should manage required references to objects
required by code deep in the hierarchy by passing them around explicitly. 
Any other solution is just bunk.

  Jp

-- 
http://catandgirl.com/view.cgi?90
-- 
 up 19 days, 1:01, 3 users, load average: 0.00, 0.02, 0.00





More information about the Python-list mailing list