Feb-06-2021, 05:14 AM
One more "What do you think you are doing?!"
But that is not the big question. The big question is why are you hiding your stockfish module by making a variable that has the same name? That is just bad programming practice as it can lead to unexpected and difficult to diagnose errors, and it is just downright confusing. Someone looking at your code will see stockfish as a module. And then they will see it is a variable. But it isn't it a module?
Here's another example where you pick a really bad variable name.
Instead of this:
import stockfish from stockfish import Stockfish ... stockfish = Stockfish("/Users/User/stockfish_20011801_x64.exe")As far as I can tell you never use the "import stockfish". You use "from stockfish import Stockfish". If you are thinking you need to import stockfish before you can from stockfish import Stockfish, that is not the case.
But that is not the big question. The big question is why are you hiding your stockfish module by making a variable that has the same name? That is just bad programming practice as it can lead to unexpected and difficult to diagnose errors, and it is just downright confusing. Someone looking at your code will see stockfish as a module. And then they will see it is a variable. But it isn't it a module?
Here's another example where you pick a really bad variable name.
eval = stockfish.get_evaluation() eval = eval["value"]eval is a Python command, as in:
print(eval('3+5'))Avoid using python keywords as variable names. Do not call something a list or a dict or eval or a type or min or max. If I wanted to use eval I could not, because you decided that eval is no longer a function that evaluates an expression, it is something that is returned by stockfish.get_evaluation(). Maybe that is an eval, but it probably isn't the standard eval.
Instead of this:
eval = stockfish.get_evaluation() eval = eval["value"]I would write
value = stockfish.get_evaluation()["value"]