Re: Py3: Import relative path module

2010-11-03 Thread Gnarlodious
OK I've had a modicum of success! However I was forced to add the path to my application folder to sys.path, which I suppose is the closest I can get to what I want. The example given then works in the shell. Apache is another problem. I added the same path to the script then Apache finds the appl

Re: Py3: Import relative path module

2010-11-03 Thread Gnarlodious
> Peter Otten wrote: > |-- alpha > |   |-- __init__.py > |   |-- beta > |   |   |-- __init__.py > |   |   `-- one.py > |   `-- two.py > `-- main.py > > 2 directories, 5 files > $ cat main.py > import alpha.beta.one > $ cat alpha/beta/one.py > from ..alpha import two > $ cat alpha/two.py > print "s

Re: Py3: Import relative path module

2010-11-03 Thread Peter Otten
Peter Otten wrote: > Peter Otten wrote: > >> Gnarlodious wrote: >> >>> On Nov 3, 2:51 am, Peter Otten wrote: >>> Slightly generalized: have the importing module print its __name__. There has to be at least one dot in the name for from .. import whatever to succeed.

Re: Py3: Import relative path module

2010-11-03 Thread Peter Otten
Peter Otten wrote: > Gnarlodious wrote: > >> On Nov 3, 2:51 am, Peter Otten wrote: >> >>> Slightly generalized: have the importing module print its __name__. >>> There has to be at least one dot in the name for >>> >>> from .. import whatever >>> >>> to succeed. >> >> Just spent about 3 hours t

Re: Py3: Import relative path module

2010-11-03 Thread Peter Otten
Gnarlodious wrote: > On Nov 3, 2:51 am, Peter Otten wrote: > >> Slightly generalized: have the importing module print its __name__. There >> has to be at least one dot in the name for >> >> from .. import whatever >> >> to succeed. > > Just spent about 3 hours trying every permutation I could th

Re: Py3: Import relative path module

2010-11-03 Thread Gnarlodious
On Nov 3, 2:51 am, Peter Otten wrote: > Slightly generalized: have the importing module print its __name__. There > has to be at least one dot in the name for > > from .. import whatever > > to succeed. Just spent about 3 hours trying every permutation I could think of, and searching Google for e

Re: Py3: Import relative path module

2010-11-03 Thread Peter Otten
MRAB wrote: > On 03/11/2010 01:48, Gnarlodious wrote: >> I admit I don't understand any of what was said here. Or why it is so >> hard what I am trying to do. I searched Google for a few hours looking >> for a way to import a module from an absolute path, but that was a >> waste of time too. >> >>

Re: Py3: Import relative path module

2010-11-02 Thread MRAB
On 03/11/2010 01:48, Gnarlodious wrote: I admit I don't understand any of what was said here. Or why it is so hard what I am trying to do. I searched Google for a few hours looking for a way to import a module from an absolute path, but that was a waste of time too. To reiterate, I am trying to

Re: Py3: Import relative path module

2010-11-02 Thread Gnarlodious
I admit I don't understand any of what was said here. Or why it is so hard what I am trying to do. I searched Google for a few hours looking for a way to import a module from an absolute path, but that was a waste of time too. To reiterate, I am trying to import a Def function from a file one leve

Re: Py3: Import relative path module

2010-11-01 Thread Terry Reedy
On 11/1/2010 6:54 AM, Gnarlodious wrote: On Nov 1, 2:16 am, Steven D'Aprano wrote: On Mon, 01 Nov 2010 01:08:52 -0700, Gnarlodious wrote: On Oct 31, 11:09 am, Дамјан Георгиевски wrote: from .. import Data.DumpHT as DumpHT That doesn't work. Any more ideas? Define "doesn't work". LOL. I

Re: Py3: Import relative path module

2010-11-01 Thread Peter Otten
Gnarlodious wrote: > On Nov 1, 5:36 am, Peter Otten wrote: > >> Remove the directory containing the importing file from your sys.path. > I removed all sys.path customizations and rebooted. > > In the following scenario, I am programming in one.py attempting to > import Data.py which is in the al

Re: Py3: Import relative path module

2010-11-01 Thread Gnarlodious
On Nov 1, 5:36 am, Peter Otten wrote: > Remove the directory containing the importing file from your sys.path. I removed all sys.path customizations and rebooted. In the following scenario, I am programming in one.py attempting to import Data.py which is in the alpha folder: > $ tree > . > `-- al

Re: Py3: Import relative path module

2010-11-01 Thread Peter Otten
Gnarlodious wrote: > On Nov 1, 2:16 am, Steven D'Aprano t...@cybersource.com.au> wrote: >> On Mon, 01 Nov 2010 01:08:52 -0700, Gnarlodious wrote: >> > On Oct 31, 11:09 am, Дамјан Георгиевски wrote: >> >> from .. import Data.DumpHT as DumpHT >> >> > That doesn't work. Any more ideas? >> >> Define

Re: Py3: Import relative path module

2010-11-01 Thread Gnarlodious
On Nov 1, 2:16 am, Steven D'Aprano wrote: > On Mon, 01 Nov 2010 01:08:52 -0700, Gnarlodious wrote: > > On Oct 31, 11:09 am, Дамјан Георгиевски wrote: > >> from .. import Data.DumpHT as DumpHT > > > That doesn't work. Any more ideas? > > Define "doesn't work". LOL. I get error: from .. import

Re: Py3: Import relative path module

2010-11-01 Thread Steven D'Aprano
On Mon, 01 Nov 2010 01:08:52 -0700, Gnarlodious wrote: > On Oct 31, 11:09 am, Дамјан Георгиевски wrote: >> from .. import Data.DumpHT as DumpHT > > That doesn't work. Any more ideas? Define "doesn't work". Does it? Print a warning message but continue execution? Import the wrong module? Abort

Re: Py3: Import relative path module

2010-10-31 Thread Дамјан Георгиевски
> I am loathe to duplicate programming in files that should just load a > copy from a module. I tried all kinds of tricks to import a module > from one level up. What's the secret? > > It works if I say: > > from Data import DumpHT > > but ONLY if the search path in sys.path. I want a relative

Py3: Import relative path module

2010-10-31 Thread Gnarlodious
I am loathe to duplicate programming in files that should just load a copy from a module. I tried all kinds of tricks to import a module from one level up. What's the secret? It works if I say: from Data import DumpHT but ONLY if the search path in sys.path. I want a relative path import indepen