Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #109099

Re: Question about imports and packages

From Terry Reedy <tjreedy@udel.edu>
Newsgroups comp.lang.python
Subject Re: Question about imports and packages
Date 2016-05-24 23:36 -0400
Message-ID <mailman.76.1464147419.20402.python-list@python.org> (permalink)
References <CAPxRSnYXQL-0zTo81_QmhXan6nJ-fzCBpS6y5DjqS952SV=yjg@mail.gmail.com> <mailman.70.1464132967.20402.python-list@python.org> <5744f9b1$0$1603$c3e8da3$5496439d@news.astraweb.com> <ni36k9$5sr$1@ger.gmane.org>

Show all headers | View raw


On 5/24/2016 9:02 PM, Steven D'Aprano wrote:
> On Wed, 25 May 2016 09:35 am, Gerald Britton wrote:
>
> For brevity, here's your package setup:
>
>
> testpkg/
> +-- __init__.py
> +-- testimport.py which runs "from testpkg.testimported import A"
> +-- testimported.py containing class A
>
> Your package layout is correct. But:

I have a similar setup, except with multiple files importing from 
imported file.  One way to make absolute imports within a package work, 
and how I do it, is to put the directory containing testpkg in a .pth 
file in the site-modules directory.  In particular, I have python.pth 
containing "F:/Python".  This effectively makes "Python" an extension of 
'site-packages', so when site-packages is searched for modules, so is 
Python.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Question about imports and packages Gerald Britton <gerald.britton@gmail.com> - 2016-05-24 19:35 -0400
  Re: Question about imports and packages Steven D'Aprano <steve@pearwood.info> - 2016-05-25 11:02 +1000
    Re: Question about imports and packages Terry Reedy <tjreedy@udel.edu> - 2016-05-24 23:36 -0400

csiph-web