Answers.Body: <p>First, engine.options["NeverClearHash"] is wrong on two counts.<br>
  It is <em>engine.option</em>, not <em>engine.options</em> and that command queries the value rather than sets it.</p>
  
  <p>To set the value you have to do something like:</p>
  
  <p>engine.configure({"NeverClearHash": 1})<br>
  or perhaps:<br>
  engine.configure({"NeverClearHash": true})</p>
  
  <p>Good programmers are never too proud to read <a href="https://python-chess.readthedocs.io/en/latest/engine.html#options" rel="nofollow noreferrer">the manual</a>. I wholeheartedly recommend it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-12T00:02:43.667Z
Answers.LastActivityDate: 2020-02-12T09:49:55.223Z
Answers.LastEditDate: 2020-02-12T09:49:55.223Z
Answers.UserDisplayName: Brian Towers
Body: <p>I have a followup question to my previous thread:
  <a href="https://chess.stackexchange.com/questions/28248/python-script-to-let-stockfish-selfplay-10-games-from-a-given-position/28249#28249">Python script to let stockfish selfplay 10 games from a given position</a></p>
  
  <p>There are some engines that allow you to set a command that imposes that the hash memory is never cleared among games. For instance the Sugar program by Marco Zerbinati has this UCI command that can be done from the command line:</p>
  
  <pre><code>setoption name NeverClearHash value true 
  </code></pre>
  
  <p>I tried to do this command in python-chess library but apparently it doesn't work:</p>
  
  <pre><code>engine.options["NeverClearHash"]
  </code></pre>
  
  <p>How can I set the option "NeverClearHash" to "true" in Python?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-11T21:25:38.733Z
Comments.Text: what exactly is the question ???????????
Comments.UserDisplayName: edwina oliver
Tags: <engines><uci><python>
Title: How can I send a UCI command to a chess engine in Python?
ThreadText: # How can I send a UCI command to a chess engine in Python?
  
  (Asked by: username_0 on 2020-02-11)
  
  I have a followup question to my previous thread:
  Python script to let stockfish selfplay 10 games from a given position
  There are some engines that allow you to set a command that imposes that the hash memory is never cleared among games. For instance the Sugar program by Marco Zerbinati has this UCI command that can be done from the command line:
  setoption name NeverClearHash value true 
  
  I tried to do this command in python-chess library but apparently it doesn't work:
  engine.options["NeverClearHash"]
  
  How can I set the option "NeverClearHash" to "true" in Python?
  
  **Tags:** engines, uci, python
  
  > **Comments:**
  > **username_1**: what exactly is the question ???????????  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-02-12. Score: 2
  
  First, engine.options["NeverClearHash"] is wrong on two counts.  
  It is *engine.option*, not *engine.options* and that command queries the value rather than sets it.
  
  To set the value you have to do something like:
  
  engine.configure({"NeverClearHash": 1})  
  or perhaps:  
  engine.configure({"NeverClearHash": true})
  
  Good programmers are never too proud to read [the manual](https://python-chess.readthedocs.io/en/latest/engine.html#options). I wholeheartedly recommend it.
  
  
  ---
  
  