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

2014-06-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 95d487abbfd8 by Terry Jan Reedy in branch '2.7':
Issue #19362: Tweek len() doc and docstring to expand the indicated range of
http://hg.python.org/cpython/rev/95d487abbfd8

New changeset 8fcbe41e1242 by Terry Jan Reedy in branch '3.4':
Issue #19362: Tweek len() doc and docstring to expand the indicated range of
http://hg.python.org/cpython/rev/8fcbe41e1242

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-06-16 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
resolution:  - fixed
stage:  - resolved
status: open - closed
versions: +Python 2.7, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-06-13 Thread Mark Lawrence

Mark Lawrence added the comment:

This is a very simple docs patch so could we have it committed please?

--
nosy: +BreamoreBoy

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-06-13 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I'll apply this (if only to bring this vacuous discussion to a close).

--
assignee: docs@python - rhettinger
priority: normal - low

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-06-13 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Raymond, I was planning to do this today along with other small patches 
(already done). Just say so and I will take it.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-06-13 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Thanks Terry.

--
assignee: rhettinger - terry.reedy

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-02-04 Thread Gareth Rees

Gareth Rees added the comment:

Here's a revised patch using Ezio's suggestion (Return the number of items of 
a sequence or container).

--
Added file: http://bugs.python.org/file33904/len-set.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-02-04 Thread Gareth Rees

Changes by Gareth Rees g...@garethrees.org:


--
title: Documentation for len() fails to mention that it works   on sets - 
Documentation for len() fails to mention that it works on sets
versions: +Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-02-04 Thread Terry J. Reedy

Terry J. Reedy added the comment:

My objection to 'container' is that it is inaccurate and leads to inaccurate 
mental models. A set is like a non-exclusive club or association, defined 
either by rule or roster, not like a box or room, which contain exclusively. I 
am 'in' the set Python Developers, but am not contained by it.

Some decades ago I was hindered by the notion that a set is like a box 
(container). A web search indicates that the top hits all have variations on 
'well-defined, unordered *collection* of objects, considered as an object in 
itself' -- wikipedia, mathisfun, wikia, brittanica, math.ku.edu.  We do a 
disservice to call a set a container.

It is true that many Python collections are implemented by containing 
references to objects (a roster) but ranges are not (a parameterized rule). The 
*collections* module is properly named.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-02-04 Thread Gareth Rees

Gareth Rees added the comment:

Here's a revised patch for Terry (Return the number of items of a sequence or 
collection.)

--
Added file: http://bugs.python.org/file33916/len-set.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-11-16 Thread Ezio Melotti

Ezio Melotti added the comment:

I think it's better to do:
-Return the number of items of a sequence or mapping.
+Return the number of items of a sequence or container.

While it's true that most sequences are clearly containers (e.g. lists), the 
same is not so evident for other types like bytes or strings.
I'm also starting from the assumption that people reading the docstring of len 
just started with Python or programming in general, so it's more important to 
keep it simple and understandable rather than being 100% accurate.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-10-27 Thread Ramchandra Apte

Ramchandra Apte added the comment:

I also prefer collection.

--
nosy: +Ramchandra Apte

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-10-25 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I would prefer 'collections with a known size' but 'collections' should be good 
enough for the doc string. The manual can follow with examples.

--
nosy: +terry.reedy

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-10-24 Thread Raymond Hettinger

Raymond Hettinger added the comment:

 Return the number of items of a container sounds 
 simple and accurate to me.

I agree this would be best.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-10-23 Thread Gareth Rees

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@python
components: Documentation
files: len-set.patch
keywords: patch
messages: 201019
nosy: Gareth.Rees, docs@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 rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-10-23 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-10-23 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Return the number of items of a container sounds simple and accurate to me.

--
nosy: +pitrou, rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-10-23 Thread Gareth Rees

Gareth Rees added the comment:

I considered suggesting container, but the problem is that container is 
used elsewhere to mean object supporting the 'in' operator (in particular, 
collections.abc.Container has a __contains__ method but no __len__ method).

The abstract base class for object with a length is collections.abc.Sized, 
but I don't think using the term sized would be clear to users.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-10-23 Thread R. David Murray

R. David Murray added the comment:

Perhaps it would be better to say that the argument may be any object with a 
__len__, such as the commonly used Python sequence and container types str, 
bytes, tuple, list, dict, and set.  After all, there are other built in types 
it works on as well: bytearray, frozenset, memoryview.

For the other, the number of items in a sequence or container type would 
mostly cover it, but at the cost of being a bit obscure.  Perhaps that's OK for 
the help text, though, since it is supposed to be a reminder, not the full 
documentation.  Another even more obscure alternative would be the number of 
items in a Sized object, which would also be more accurate (since an object 
with a __len__ doesn't *have* to conform fully to the sequence or container 
ABCs...nor does a container *have* to implement __len__).

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-10-23 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 Perhaps it would be better to say that the argument may be any
 object with a __len__, such as the commonly used Python sequence and
 container types str, bytes, tuple, list, dict, and set.  After all,
 there are other built in types it works on as well: bytearray,
 frozenset, memoryview.

__len__ is an implementation detail for experts. Beginners don't need
to know about __len__ in order to understand querying the length of
a container. Similarly, they don't need to know about ABCs to understand,
intuitively, what a container is ;-)

--
title: Documentation for len() fails to mention that it works on sets - 
Documentation for len() fails to mention that it works on sets

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-10-23 Thread R. David Murray

R. David Murray added the comment:

I thought we were talking about the reference guide, not the tutorial?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-10-23 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Well, the patch is for the builtins documentation as well as len.__doc__.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19362
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com