You are not logged in.

#1 2007-05-21 19:12:31

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Python Import

I seem to be having a rather annoying import issue with python. I am programming a small game using pygame, I'm almost complete with it, but have become rather annoyed that my source code for it is rather ugly and unordered. I wanted to be able to remove certain segments of code, for example, enemy code, character code, ect. In different files, and just use python to access them. I figured out that from <blah> import * would be the best way, but since some of the code, image directories ect, is in the main program, the other modules complain about not being able to access the images, saying they don't exsist. I tried module.Img.character and still the same error persist. Any ideas on what I am doign wrong?

Offline

#2 2007-05-22 06:01:41

gradgrind
Member
From: Germany
Registered: 2005-10-06
Posts: 921

Re: Python Import

I'm not quite sure what you're asking (what is 'module.Img.character' supposed to be/do?), but it sounds like you might need to move the stuff that is needed by various non-main modules out of the main module - to avoid looping dependencies.
Also 'from <blah> import *' should be used with caution, it is normally better to import names explicitly, or else just do 'import <blah>', to avoid name clashes, etc.

Offline

Board footer

Powered by FluxBB