I am writing a GAE application and am having some difficulty with the following problem.
I've created multiple python files (say a.py and b.py) which are both stored in the same folder. I am able to call code in a.py or b.py by mapping URL's to them (using app.yaml). What I haven't figured out how to do is import the code from one into another.
Can anyone help me with the syntax and/or any config that is required here? For instance, I am under the impression that I can include the code from b.py in the file a.py by issuing the following statement in a.py
import b
I'm not having any success with this approach. Specifically I receive this error:
ImportError: No module named b
Any suggestions?
Thanks,
Matt
If the files a.py and b.py aren't located, be sure to include the respective paths in
sys.path
.Have you tried importing as if you were starting at the top level? Like
Note that the usual pattern with GAE is not to have each one independently mapped in app.yaml, but rather to have a single 'handler' script that has all (or all but static and special) URLs mapped to it, and have that script import both a and b and use Handlers they define.
as @toby said, it must be imported as if importing from the top directory, and a file named init.py must be placed in the folder.