[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Directories



I'm trying to organize my code better. I've got modules and data files organized into directories like so:

Main Game Directory
  -Music, sound, etc.
  -Conch (sound code)
  -Aquablue (worldsim)
  -Driftwood (UI)
  -Pearl (Isometric display)

And here I've encountered a problem. I've been able to test each module on its own, and even have them automatically go up one directory to access the right data files when run alone by saying:

if __name__ != "__main__": ## Run when included in something else
    print "Loaded module "+MODULE_NAME+"."
else: ## Run when this program is run by itself
    print "Running module "+MODULE_NAME+", v"+VERSION
    if MODULE_NOTES:
        print MODULE_NOTES

    ## Switch to the next directory up to find data directories.
    os.chdir(os.path.split(os.getcwd())[0])

But the part I'm working on right now, the "Pearl" display, needs to access the Aquablue worldsim code just to be properly tested. If I put "import Aquablue" below the code I just gave, it can't find the module even though it can access the data-file directories. Will I have to either put Pearl in the main game directory so it can find Aquablue, or test it without that?

Kris