[docs] [issue19362] Documentation for len() fails to mention that it works on sets

Gareth Rees report at bugs.python.org
Wed Oct 23 14:22:08 CEST 2013


New submission from Gareth Rees:

The help text for the len() built-in function says:

    Return the number of items of a sequence or mapping.

This omits to mention that len() works on sets too. I suggest this be changed to:

    Return the number of items of a sequence, mapping, or set.

Similarly, the documentation for len() says:

    The argument may be a sequence (string, tuple or list) or a mapping (dictionary).

I suggest this be changed to

    The argument may be a sequence (string, tuple or list), a mapping (dictionary), or a set.

(Of course, strictly speaking, len() accepts any object with a __len__ method, but sequences, mappings and sets are the ones that are built-in to the Python core, and so these are the ones it is important to mention in the help and the documentation.)

----------
assignee: docs at python
components: Documentation
files: len-set.patch
keywords: patch
messages: 201019
nosy: Gareth.Rees, docs at python
priority: normal
severity: normal
status: open
title: Documentation for len() fails to mention that it works on sets
type: enhancement
Added file: http://bugs.python.org/file32313/len-set.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19362>
_______________________________________


More information about the docs mailing list