Currently I have a python file that goes like this (really simplified):
u = 30
colors = ('blue', 'red')
grid = [0, 1]
class entity:
def __init___(self, x, color)
self.x = x
self.color = color
def move(self):
print(grid[self.x + 1], self.color)
foo = entity(0, 'blue')
bar = entity(0, 'red')
while true:
foo.move()
bar.move()
I tried to split it out and I got this:
# initialisation.py
u = 30
colors = ('blue', 'red')
# grid_map.py
from initialisation import u, colors
grid = [0, 1]
# classes.py
from map import u, colors, grid # or *
class entity:
def __init___(self, x, color)
self.x = x
self.color = color
def move(self):
print(grid[self.x + 1], self.color)
# objects.py
from classes import u, colors, grid, entity # or *
foo = entity(0, 'blue')
bar = entity(0, 'red')
# main.py
from objects import u, colors, grid, entity, foo, bar # or *
while true:
foo.move()
bar.move()
Now, I feel like I should be importing in a way that isn't this import-chain from one file to the next, but I'm unsure exactly how.
(hopefully this is a minimal, reproducible example)