classification
Title: FAQ: len() is still function for good reason.
Type: Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, inada.naoki, miss-islington, terry.reedy, vstinner
Priority: normal Keywords: patch

Created on 2016-08-03 09:01 by inada.naoki, last changed 2018-07-31 07:37 by inada.naoki. This issue is now closed.

Files
File name Uploaded Description Edit
faq-function-method.patch inada.naoki, 2016-12-26 12:00 review
Pull Requests
URL Status Linked Edit
PR 8432 merged inada.naoki, 2018-07-24 06:21
PR 8577 merged miss-islington, 2018-07-31 05:49
PR 8578 merged miss-islington, 2018-07-31 05:50
PR 8579 merged miss-islington, 2018-07-31 05:51
Messages (7)
msg271881 - (view) Author: Inada Naoki (inada.naoki) * (Python committer) Date: 2016-08-03 09:01
https://docs.python.org/3/faq/design.html#why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list

> The major reason is history.
...
> but it’s a part of Python, and it’s too late to make such fundamental changes now. The functions have to remain to avoid massive code breakage.

People seeing this answer may think "it's bad design, but remains for historical reason."

But there is more positive reason why len is still function.
http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list.htm
msg272051 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-08-05 18:53
I agree. We do not need to semi-apologize for having generic functions be builtin generic functions.
msg284023 - (view) Author: Inada Naoki (inada.naoki) * (Python committer) Date: 2016-12-26 12:00
I can't write long English document.
Can I quote Guido's mail instead?
msg322721 - (view) Author: Inada Naoki (inada.naoki) * (Python committer) Date: 2018-07-31 05:49
New changeset c48e26dcadbff8620bb5881d3bd148fc8894d0ef by INADA Naoki in branch 'master':
bpo-27671: Update FAQ about why len is function (GH-8432)
https://github.com/python/cpython/commit/c48e26dcadbff8620bb5881d3bd148fc8894d0ef
msg322723 - (view) Author: miss-islington (miss-islington) Date: 2018-07-31 05:54
New changeset a621f406402e05febb302cf31962e9d2d747d8f6 by Miss Islington (bot) in branch '3.7':
bpo-27671: Update FAQ about why len is function (GH-8432)
https://github.com/python/cpython/commit/a621f406402e05febb302cf31962e9d2d747d8f6
msg322724 - (view) Author: miss-islington (miss-islington) Date: 2018-07-31 05:56
New changeset 0b376eb0d63e0c51ed55c620b40edae6ded4ea48 by Miss Islington (bot) in branch '3.6':
bpo-27671: Update FAQ about why len is function (GH-8432)
https://github.com/python/cpython/commit/0b376eb0d63e0c51ed55c620b40edae6ded4ea48
msg322725 - (view) Author: miss-islington (miss-islington) Date: 2018-07-31 05:58
New changeset dc9039da239ee572eaaf56e4a026be1fc4d74e24 by Miss Islington (bot) in branch '2.7':
bpo-27671: Update FAQ about why len is function (GH-8432)
https://github.com/python/cpython/commit/dc9039da239ee572eaaf56e4a026be1fc4d74e24
History
Date User Action Args
2018-07-31 07:37:40inada.naokisetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-07-31 05:58:14miss-islingtonsetmessages: + msg322725
2018-07-31 05:56:29miss-islingtonsetmessages: + msg322724
2018-07-31 05:54:27miss-islingtonsetnosy: + miss-islington
messages: + msg322723
2018-07-31 05:51:33miss-islingtonsetpull_requests: + pull_request8087
2018-07-31 05:50:33miss-islingtonsetpull_requests: + pull_request8086
2018-07-31 05:49:40miss-islingtonsetpull_requests: + pull_request8085
2018-07-31 05:49:26inada.naokisetmessages: + msg322721
2018-07-24 06:21:52inada.naokisetstage: patch review
pull_requests: + pull_request7957
2017-01-03 14:35:54vstinnersetnosy: + vstinner
2016-12-26 12:00:29inada.naokisetfiles: + faq-function-method.patch
keywords: + patch
messages: + msg284023
2016-08-05 18:53:42terry.reedysetnosy: + terry.reedy
messages: + msg272051
2016-08-03 09:01:26inada.naokicreate