TinyCircuits Forum

TinyCircuits Products => Thumby => Topic started by: allisonsinger on September 10, 2025, 05:49:52 AM

Title: Importing files
Post by: allisonsinger on September 10, 2025, 05:49:52 AM
Hello,
I've been working on developing a game for about a week, but I'm encountering some problems with importing separate files. I would greatly appreciate any help!
Directory Structure:
/
    Games
        BattleGame
            BattleGame.py
            characters.py
            moves.py
Should I keep everything in a single file? I've noticed that most other games are structured this way. I'd prefer to separate data from the game logic, but I don't want to compromise on resources. How can I import a file from the same game directory? I keep encountering a "module not found" error no matter what I try.
I've tried the following:
from moves import moves
from Games.BattleGame.moves import moves
Title: Re: Importing files
Post by: AyreGuitar on December 19, 2025, 04:00:20 AM
Try doing this to set the current directory to your game folder before importing your modules:
from os import chdir
chdir("/Games/BattleGame/")
Then you should be able to import normally, eg:
from moves import moves