If I run game_data.py directly it runs fine. But if I run mygame.py, it give the error:
Traceback (most recent call last):
File "/home/a/Desktop/escape/mygame.py", line 4, in <module>
from foo import *
File "/home/a/Desktop/escape/game_data.py", line 2, in <module>
imglist = [images.floor, images.pillar, images.soil]
NameError: name 'images' is not defined
What is the correct way for one script to import another if both rely on pgzero functionality?
Let's say I have a script with the main game logic, and a separate script to hold long repetitive data objects.
game_data.py
mygame.py:
If I run
game_data.py
directly it runs fine. But if I runmygame.py
, it give the error:What is the correct way for one script to import another if both rely on pgzero functionality?
Thanks.