This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Unfortunate naming of variable in heapq example
Type: Stage:
Components: Documentation Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, ranang
Priority: normal Keywords:

Created on 2006-11-08 09:46 by ranang, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg30477 - (view) Author: Martin Thorsen Ranang (ranang) Date: 2006-11-08 09:46
In the current "Python Library Reference"
documentation, in section "5.4 heapq -- Heap queue
algorithm", an example goes:

>>> sorted = []
>>> while heap:
...     sorted.append(heappop(heap))
...
>>> print sorted
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

However, 'sorted' is the name of a built-in function. 
Of course, the example does not constitute an error,
but it might be misleading to new users of the
language.  Consider:

>>> sorted = []
>>> should_be_sorted = sorted([4, 3, 1, 2])
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: 'list' object is not callable
>>> 

Hence, I suggest to rename the variable in the example
to 'ordered'.

Yours,



Martin Thorsen Ranang
msg30478 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-11-08 10:04
Logged In: YES 
user_id=849994

Thanks! Fixed in rev. 52668, 52669 (2.5).
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44209
2006-11-08 09:46:39ranangcreate