<div dir="ltr">Hello Andrew,<div><br></div><div>You are right. The task should not be pop'ed out of the entry_finder dictionary. I prefer the 2nd approach over the 1st one where the task is re-added back to the dictionary.</div><div><br></div><div><pre style="padding:5px;line-height:15.6px;border-top-width:1px;border-bottom-width:1px;border-style:solid none;border-top-color:rgb(170,204,153);border-bottom-color:rgb(170,204,153);background-color:rgb(238,255,204)"><span class="" style="color:rgb(0,112,32);font-weight:bold">def</span><font color="#333333"> </font><span class="" style="color:rgb(6,40,126)">remove_task</span><span class="" style="color:rgb(51,51,51)">(</span><span class="" style="color:rgb(51,51,51)">task</span><span class="" style="color:rgb(51,51,51)">):</span><font color="#333333">
    </font><span class="" style="color:rgb(64,112,160)">'Mark an existing task as REMOVED.  Raise KeyError if not found.'</span><font color="#333333">
    </font><span class=""><font color="#333333">entry_finder</font><font color="#666666">[</font></span><span class="" style="color:rgb(51,51,51)">task][-1] = REMOVED</span><font color="#333333">
</font></pre></div><div><span class="">I will correct it in the docs.</span></div><div><span class=""><br></span></div><div><span class="">-- <br>Senthil</span></div><div><span class=""><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 6, 2016 at 3:42 AM, Andrew McFarland <span dir="ltr"><<a href="mailto:andrew.mcfarland@outlook.com" target="_blank">andrew.mcfarland@outlook.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div dir="ltr">page in question:   <a href="https://docs.python.org/2/library/heapq.html" target="_blank">https://docs.python.org/2/library/heapq.html</a><div><br></div><div>section:   <u> 8.4.2. Priority Queue Implementation Notes</u></div><div><br></div><div>Currently:</div><div><br></div><div><br></div><div><div>def remove_task(task):</div><div>    'Mark an existing task as REMOVED.  Raise KeyError if not found.'</div><div>    entry = entry_finder.pop(task)</div><div>    entry[-1] = REMOVED</div></div><div><br></div><div><br></div><div><span style="font-size:12pt">As it stands, 'task' is removed from dictionary 'entry_finder' and never replaced which is not the intention in my opinion.</span></div><div><span style="font-size:12pt"><br></span></div><div>Possible fixes:</div><div><br></div><div>1.</div><div><div>def remove_task(task):</div><div>    'Mark an existing task as REMOVED.  Raise KeyError if not found.'</div><div>    entry = entry_finder.pop(task)</div><div>    entry[-1] = REMOVED</div></div><div> <font color="#d24726">   <span style="font-size:12pt">entry_finder[task] = entry</span></font></div><div><br></div><div><br></div><div>2.</div><div><div>def remove_task(task):</div><div>    'Mark an existing task as REMOVED.  Raise KeyError if not found.'</div><div>   <font color="#d24726"> entry_finder[task][-1] = <span style="font-size:12pt">REMOVED</span></font></div></div><div><br></div><div><br></div><div>Sincerely,</div><div>AM</div><div><br></div><div><br></div><div><br></div>                                          </div></div>
<br>_______________________________________________<br>
docs mailing list<br>
<a href="mailto:docs@python.org">docs@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/docs" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/docs</a><br>
<br></blockquote></div><br></div>