Re: Add directory to sys.path based on variable

2014-01-30 Thread loial
Idiot that I am...I was not calling the script with the full path ! Thanks for your help -- https://mail.python.org/mailman/listinfo/python-list

Re: Add directory to sys.path based on variable

2014-01-30 Thread Tim Golden
On 30/01/2014 14:03, loial wrote: > Ok, that works fine with the apth hard coded, but I want to do something like > the code below. i.e I am trying to dynamically add a path that is relative to > the path of the current executing python script. > > In this case the import fails. > > import sys

Re: Add directory to sys.path based on variable

2014-01-30 Thread Chris Angelico
On Fri, Jan 31, 2014 at 1:03 AM, loial wrote: > In this case the import fails. > > import sys > import os > from os.path import * Not sure why you need that, since you're explicitly naming "os.path.dirname". The base "import os" shoul cover that for you. > scriptpath=os.path.dirname(sys.argv[0])

Re: Add directory to sys.path based on variable

2014-01-30 Thread loial
Ok, that works fine with the apth hard coded, but I want to do something like the code below. i.e I am trying to dynamically add a path that is relative to the path of the current executing python script. In this case the import fails. import sys import os from os.path import * scriptpath=os.p

Re: Add directory to sys.path based on variable

2014-01-30 Thread Tim Golden
On 30/01/2014 12:39, loial wrote: > I want to add a path to sys.path based upon a variable > > Can I do that? > > Hardcodeing the path works fine, but I want to set it based upon a > variable. > > I know I can set PYTHONPATH, but just wondering if I can add a > directory on the fly to sys.path u

Add directory to sys.path based on variable

2014-01-30 Thread loial
I want to add a path to sys.path based upon a variable Can I do that? Hardcodeing the path works fine, but I want to set it based upon a variable. I know I can set PYTHONPATH, but just wondering if I can add a directory on the fly to sys.path using a variable -- https://mail.python.org/ma