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

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -