F
flupke
Hi,
i have a program with is built like this:
startup.py
dir1/__init__.py
dir1/file1.py
dir2/__init__.py
dir2/file2.py
dir3/__init__.py
dir3/file3.py
The program works but now i want to add the functionality into an
existing program 2. This is program 2:
program2.py
program2dir1/__init__.py
program2dir1/file4.py
When i copy the directories over i get this situation:
program2.py
program2dir1/__init__.py
program2dir1/file4.py
program1/__init__.py
program1/dir1/__init__.py
program1/dir1/file1.py
program1/dir2/__init__.py
program1/dir2/file2.py
program1/dir3/__init__.py
program1/dir3/file3.py
However, i need to specify this in program2.py or i can't use the files 1-3:
import sys
sys.path.append('program1')
import program1.dir1.file1 as f1
Then i can use the functionality of the first program in the second.
Now for my questions:
1. Is this the correct way or is there an easier/more logical sollution.
Now all __init__.py file are empty
2. As said this works but when i make a standalone of program2 it
doesn't find any of the program1 files:
Traceback (most recent call last):
File "start.py", line 20, in ?
File "windows\windowmain.pyo", line 59, in ?
File "program1\__init__.pyo", line 2, in ?
File "program1\dir1\__init__.pyo", line 1, in ?
File "program1\dir1\file1.pyo", line 28, in ?
ImportError: No module named dir2.file2
dir2.file2 is imported in file1.py as import dir2.file2.
So something in my setup script is wrong. How can i make sure all file
of program1 are also added?
Excerpt of setup.py
....
py_modules=['start'],
packages=['database','dialogs','export','graphics','localutils','windows'],
....
If i specify program1 as module or as package or program1.dir1 and so on
doesn't seem to help.
Any ideas?
Thanks
Benedict
i have a program with is built like this:
startup.py
dir1/__init__.py
dir1/file1.py
dir2/__init__.py
dir2/file2.py
dir3/__init__.py
dir3/file3.py
The program works but now i want to add the functionality into an
existing program 2. This is program 2:
program2.py
program2dir1/__init__.py
program2dir1/file4.py
When i copy the directories over i get this situation:
program2.py
program2dir1/__init__.py
program2dir1/file4.py
program1/__init__.py
program1/dir1/__init__.py
program1/dir1/file1.py
program1/dir2/__init__.py
program1/dir2/file2.py
program1/dir3/__init__.py
program1/dir3/file3.py
However, i need to specify this in program2.py or i can't use the files 1-3:
import sys
sys.path.append('program1')
import program1.dir1.file1 as f1
Then i can use the functionality of the first program in the second.
Now for my questions:
1. Is this the correct way or is there an easier/more logical sollution.
Now all __init__.py file are empty
2. As said this works but when i make a standalone of program2 it
doesn't find any of the program1 files:
Traceback (most recent call last):
File "start.py", line 20, in ?
File "windows\windowmain.pyo", line 59, in ?
File "program1\__init__.pyo", line 2, in ?
File "program1\dir1\__init__.pyo", line 1, in ?
File "program1\dir1\file1.pyo", line 28, in ?
ImportError: No module named dir2.file2
dir2.file2 is imported in file1.py as import dir2.file2.
So something in my setup script is wrong. How can i make sure all file
of program1 are also added?
Excerpt of setup.py
....
py_modules=['start'],
packages=['database','dialogs','export','graphics','localutils','windows'],
....
If i specify program1 as module or as package or program1.dir1 and so on
doesn't seem to help.
Any ideas?
Thanks
Benedict