Linking files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cosmere
    New Member
    • Sep 2023
    • 1

    Linking files

    Hello I'm trying to create a basic game in python using OOP style programming. The problem is that I'm not sure how to link my files. I currently have main.py, a game.py and a logic.py. I would like to be able to run everything from my main.py through the start_game method. However if I run the code below I get the following error: TypeError: Main.start_game () takes 0 positional arguments but 1 was given. I'm just a beginner so I'm not sure if I'm approaching this the right way. My current code looks like this:

    from game import Game

    class Main():
    def __init__(self):
    self.game = Game
    def start_game():
    player_choice = Game.player_cho ice()
    print(player_ch oice)

    if __name__ == '__main__':
    main = Main()
    print(main.star t_game())
Working...