Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import python script files in folders on Google App Engine?

I'm fairly new to both Python and Google App Engine. I want to organize my script files by creating a folder structure. However when I do that I can no longer figure out how to import them.

For example:

main.py
/eggs/spam.py

How do I import spam.py in main.py?

like image 676
Will Curran Avatar asked Apr 01 '11 18:04

Will Curran


1 Answers

Make eggs a package by adding an __init__.py file in the folder. It can be empty, as long as it's there. Then, import spam like this:

import eggs.spam

More information on packages.

like image 176
Håvard Avatar answered Oct 18 '22 07:10

Håvard