[Tutor] accessing modules found throughout a package?

Alex Kleider akleider at sonic.net
Sun Oct 18 13:51:34 EDT 2015


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 sys.path:
>>      sys.path.append('path/to/top/level/package/directory')
> 
> You could, but you can also add it to your PYTHONPATH environment 
> variable.

It seems to not exist:
(venv)alex at x301:~/Py/CSV/debk$ echo $PYTHONPATH

Should I add the following to the end of my ~/.bashrc file?
export PYTHONPATH="$PYTHONPATH:/home/alex/Py"



More information about the Tutor mailing list