Skip to content
Advertisement

How can I call a class method on an instance within a different class __init__

I am creating a tic-tac-toe game in python. I’m trying to call the update method from my Board class on my boardState object within the class init of my Turn class. When I run it I get NameError: name boardState is not defined.

JavaScript

Advertisement

Answer

you are getting this error siense you haven’t defined “boardState” before referencing it,

you need to set it to be a new Board Object before using it

JavaScript

this should fix your problem

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement