[Tutor] python import problem

kakada hokkakada at khmeros.info
Thu Aug 10 03:11:05 CEST 2006

បានសរសេរ Alan Gauld:
Hi Alan,
>> the folders modules and translate are in the same level, so if I want to
>> import factory.py into myfile.py, how can I do?
> You need to make your folders into packages.
> Its fairly simple, you basically create an init.py file
> But its worth reading about packages in the docs
> Come back here ifv you have any questions after that.
Sure, I can do it if I move translate folder into modules folder then
create an empty init.py file.
But I want another way, and PYTHONPATH is your right suggestion
> The other way would be to add each folder to
It works for me now:

mport sys
import os.path
sys.path.append(os.path.join(sys.path[0] ,"translate"))


More information about the Tutor mailing list