Re: [Tutor] accessing modules found throughout a package?

2015-10-19 Thread Alex Kleider
On 2015-10-18 18:01, Steven D'Aprano wrote: On Sun, Oct 18, 2015 at 08:07:07AM -0700, Alex Kleider wrote: On 2015-10-17 19:49, Steven D'Aprano wrote: >which will work from your package's callers, and from within the >package >itself provided the top level directory can be found within Python's

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Steven D'Aprano
On Sun, Oct 18, 2015 at 08:07:07AM -0700, Alex Kleider wrote: > On 2015-10-17 19:49, Steven D'Aprano wrote: > > >which will work from your package's callers, and from within the > >package > >itself provided the top level directory can be found within Python's > >path. Within the package you can

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Ben Finney
Alex Kleider writes: > Should I add the following to the end of my ~/.bashrc file? > export PYTHONPATH="$PYTHONPATH:/home/alex/Py" No, because the entry should only be in PYTHONPATH *if* you want imports to come from that package. So the advice is: * For the run-time

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Ben Finney
Ben Finney writes: > * Python will automatically add a ‘sys.path’ entry for the directory > containing the script named on the command line. So this: > > $ cd ~/Projects/lorem/ > $ python3 ./setup.py test > > will run the ‘setup.py’ program with

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Alex Kleider
On 2015-10-18 08:07, Alex Kleider wrote: On 2015-10-17 19:49, Steven D'Aprano wrote: which will work from your package's callers, and from within the package itself provided the top level directory can be found within Python's path. Within the package you can also use relative imports, see

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Alex Kleider
On 2015-10-17 19:49, Steven D'Aprano wrote: which will work from your package's callers, and from within the package itself provided the top level directory can be found within Python's path. Within the package you can also use relative imports, see the docs for more detail. How does one

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Martin A. Brown
Hello Alex, How does one arrange so "the top level directory _can_ be found within Python's path."? >>> >>> Is the answer to include the following at the beginning of each file? >>> >>> if not 'path/to/top/level/package/directory' in sys.path: >>>

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Alan Gauld
On 18/10/15 16:33, Alex Kleider wrote: How does one arrange so "the top level directory _can_ be found within Python's path."? Is the answer to include the following at the beginning of each file? if not 'path/to/top/level/package/directory' in sys.path:

Re: [Tutor] accessing modules found throughout a package?

2015-10-18 Thread Alex Kleider
On 2015-10-18 10:26, Alan Gauld wrote: On 18/10/15 16:33, Alex Kleider wrote: How does one arrange so "the top level directory _can_ be found within Python's path."? Is the answer to include the following at the beginning of each file? if not 'path/to/top/level/package/directory' in

Re: [Tutor] accessing modules found throughout a package?

2015-10-17 Thread Ben Finney
James Hartley writes: > In my current project, I am developing a package. It makes sense to > embed tests throughout the package's directory structure as they > should be part of the package & its distribution. Yet, as you're finding, it also causes headaches. First, know

Re: [Tutor] accessing modules found throughout a package?

2015-10-17 Thread Steven D'Aprano
On Sat, Oct 17, 2015 at 08:20:14PM -0500, James Hartley wrote: > In my current project, I am developing a package. It makes sense to embed > tests throughout the package's directory structure as they should be part > of the package & its distribution. It may raise eyebrows that I have tests >

[Tutor] accessing modules found throughout a package?

2015-10-17 Thread James Hartley
In my current project, I am developing a package. It makes sense to embed tests throughout the package's directory structure as they should be part of the package & its distribution. It may raise eyebrows that I have tests sprinkled through various directories, but there are reasons for keeping