python - importing a module that imports the main module -
i'm working on text adventure stores levels massive dictionary called 'places'. instead of having in main file, thought make separate file called 'levels.py' contain it, making code cleaner , eliminating need go through 450+ lines of other code add it.
so, main game file:
from levels import places class thing: #some stuff
levels.py:
from game import * places = { "bleh" : thing("bleh"), }
it seems 'places' isn't defined in game, however.
i think what's happening there's import 'loop'. however, if levels.py needs import classes game.py, how prevent that?
it's possible refactor eliminate circular dependencies. move thing
thing.py
, in game.py
, in levels.py
use from thing import thing
. rinse , repeat.
Comments
Post a Comment