Python code erasing variables for no reason
Go to solution
Solved by geomac,
Python has a "fun" way of assigning references instead of actual values to variables at most times. Based on the code you presented, if all the cells in the <self.__snakeCells> list are references to the same object, it may being set to a `None` value at some point in your code -- If I'm reading it correctly probably in this line:
self.__snakeCells[-1].becomeEmpty()
The copy library is your friend, I've used <copy.copy(obj)> and <copy.deepcopy(obj)> to get around these kind of reference issues.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now