[issue22725] improve documentation for enumerate() (built-in function)

2015-06-02 Thread R. David Murray

R. David Murray added the comment:

Per Raymond's last message, closing this as rejected.

--
assignee: rhettinger - docs@python
stage: needs patch - resolved

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-11-05 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I'm sorry but I do not like the proposed patch at all.  The wording is awkward 
which when iterated and has weird terminology the sequence number.

The OP's concern about the *sequence* versus *iterable* parameter name has been 
addressed (it is part of the 2.7 API and is unchangeable).

I see no need for revising the text which already discusses sequence or some 
other object that supports iterable, that has clear examples, and that has 
pure python equivalent code.   The existing wording has worked well for most 
people for the better part of a decade.

--
resolution:  - rejected
status: open - closed

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-11-04 Thread R. David Murray

R. David Murray added the comment:

Specifically, this works (in 2.7):

   enumerate(sequence=myvar)

Changing sequence to iterable would break any code that was written like the 
above.

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-11-04 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-11-04 Thread Tshepang Lekhonkhobe

Tshepang Lekhonkhobe added the comment:

Oh, I see now. The documentation doesn't make it clear.

Anyways, what were the advantages of making it a keyword, instead of
just a positional argument?

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-11-04 Thread Georg Brandl

Georg Brandl added the comment:

Missing keyword argument support is not the norm, it's the exception that is 
only due to implementation details in C code. Eventually, we'd like every C 
function to support keyword arguments.

Converting everything is tedious work, though, and still makes things slower 
(that may become less of an issue eventually with Clinic), so only select 
functions are converted.

Functions are good candidates for keyword argument support when they have 
parameters that are best passed as keywords, such as

enumerate(x, start=5)

which makes it immediately clear what the second parameter does.

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-11-03 Thread Tshepang Lekhonkhobe

Tshepang Lekhonkhobe added the comment:

@raymond

Why do you say that 'sequence' is a keyword?

 enumerate()
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: Required argument 'sequence' (pos 1) not found

That means that 'sequence' can be changed to 'iterable' without worrying about 
backwards compatibility.

--
nosy: +tshepang

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-11-03 Thread Raymond Hettinger

Raymond Hettinger added the comment:

static PyObject *
 Why do you say that 'sequence' is a keyword?

It is a keyword argument to enumerate().  Here's the relevant section of code:

enum_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
enumobject *en;
PyObject *seq = NULL;
PyObject *start = NULL;
static char *kwlist[] = {sequence, start, 0};

if (!PyArg_ParseTupleAndKeywords(args, kwds, O|O:enumerate, kwlist,
 seq, start))
return NULL

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-11-02 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
keywords: +patch
Added file: http://bugs.python.org/file37111/enumerate-doc.2.7.patch

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-11-02 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


Added file: http://bugs.python.org/file37112/enumerate_doc-3.4.patch

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-31 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The first argument of enumerate is 'iterable' in the 2.7 docstring also.

enumerate(iterable[, start]) - iterator for index, value of iterable

Return an enumerate object.  iterable must be another object that 
supportsniteration.  The enumerate object yields pairs containing a count 
(from\nstart, which defaults to zero) and a value yielded by the iterable 
argument.  enumerate is useful for obtaining an indexed list:   (0, seq[0]), 
(1, seq[1]), (2, seq[2]), ...

We should update at least that part of the doc entry.

--
nosy: +terry.reedy
stage:  - needs patch
versions:  -Python 3.6

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-31 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The sequence parameter name is an unfortunate hold-over from olden times were 
many things that accepted iterables were marked as taking sequences.

This was fixed in Python 3, but it can't be changed in Py2.7 because the 
parameter name is exposed as a keyword argument:

 list(enumerate(sequence='abc', start=2))
[(2, 'a'), (3, 'b'), (4, 'c')]

The rest docs for Python 2.7 read just fine, Return an enumerate object. 
sequence must be a sequence, an iterator, or some other object which supports 
iteration.   I think that is sufficient to clarify any confusion caused by the 
unfortunate choice of keyword argument name.

--
assignee: docs@python - rhettinger
nosy: +rhettinger
resolution:  - rejected
status: open - closed
versions:  -Python 3.4, Python 3.5

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-31 Thread R. David Murray

R. David Murray added the comment:

We have a suggestion for a wording improvement (that does not change the 
sentence to which you refer) that has been accepted as better than the existing 
wording by a couple of committers.  This improvement is actually independent of 
what the variable is named.  The 2.7 docstring should also be fixed to show the 
actual argument name, IMO.

--
resolution: rejected - 
status: closed - open
versions: +Python 3.4, Python 3.5

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-31 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Can you attach a proposed patch and I will make a decision.  

FWIW, I'm very happy with the current documentation at 
https://docs.python.org/2.7/library/functions.html#enumerate  Between the text, 
example, and pure python equivalent, it does a great job communicating what 
enumerate is supposed to do.

Proposed improvements to the docstring should match the main documentation as 
much as possible.

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-28 Thread Georg Brandl

Georg Brandl added the comment:

rdm: your suggestion sounds good. Note that the argument name is iterable in 
Py3.

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-27 Thread Georg Brandl

Georg Brandl added the comment:

next() is quite unlike match() and search(), as you almost never use next() on 
iterators directly. Rather, the iterator is iterated by constructs like a for 
loop or a comprehension, or another function that consumes it (list, map, ...)

--
nosy: +georg.brandl

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-27 Thread Van Ly

Van Ly added the comment:

While next() is rarely used directly on iterators, as you say, it may help to 
remind the experienced reader of the mechanical characteristic in essence which 
a new reader on first approach uses to construct a mental model.

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-27 Thread Ethan Furman

Ethan Furman added the comment:

I do not think 'next' is needed in this context.  Unlike 'match' and 'search', 
'next' is a function that can be used with any iterator and mentioning it here 
is unnecessary.

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-27 Thread R. David Murray

R. David Murray added the comment:

That would not be consistent with the rest of the docs.  Consider, for example, 
that the full documetation of dictionary views 
(https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects), 
which are iterables in much the same way that the enumerate object is, does not 
mention next.  The glossary link to iterable will lead the reader to the 
discussion of next, which is a fundamental Python concept and does not need to 
be repeated.  In my opinion, of course, others may disagree.

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-26 Thread Van Ly

Van Ly added the comment:

Reference by the guide to next() should stay for the same reason in 
re.compile() a regular expression object is returned and the two methods are 
mentioned, match() and search(). They are useful to know in that context in as 
much as next() is useful to know here. IMO.

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-25 Thread Van Ly

Van Ly added the comment:

I don't want to argue. Ask a 12-year old and their English teacher, Does the 
second sentence qualify as gobbledygook even if it is technically correct and 
complete and not verbose?

To be constructive and take on what has been said, an iteration on improving 
the wording: 

-- improve wording as follows:

enumerate(iteratable, start=0)

Accepts an iteratable[typo for iterable?] and returns an iterator, a special 
case 'enumerate object'. The method iterator.next() returns a tuple which pairs 
an index counter with the object at the index in iterable.

 led = ['red', 'green', 'blue']
led = ['red', 'green', 'blue']
 iter = enumerate(led)
iter = enumerate(led)
 iter.next()
iter.next()
(0, 'red')
 iter.next()
iter.next()
(1, 'green')
 iter.next()
iter.next()
(2, 'blue')

# While enumerate does not return a list of pairs, 
# it is easy to collect the pairs and construct a list as follows
 list(enumerate(led))
list(enumerate(led))
[(0, 'red'), (1, 'green'), (2, 'blue')]

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-25 Thread Ethan Furman

Ethan Furman added the comment:

rdm was not asking for an argument, he was asking for a more detailed 
explanation of what was confusing.  Your initial response lacked courtesy and 
respect, and is not appreciated.

The rest of your reply was much better.  Next time, please skip the 
non-constructive portion.

--
nosy: +ethan.furman

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-25 Thread Van Ly

Van Ly added the comment:

Understood. I felt the problem was self evident with sequence must be a 
sequence.

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-25 Thread Georg Brandl

Georg Brandl added the comment:

 I felt the problem was self evident with sequence must be a sequence.

The two words are not used in the same sense: the first names the argument of 
the function, the second is one of several possible object types you can pass 
for that argument.

--
nosy: +georg.brandl

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-25 Thread Van Ly

Van Ly added the comment:

 sequence must be a sequence

The subtle minutiae of aficionados necessary to interpret the meaning of those 
two words in their distinct relation is opaque to a new comer and doesn’t serve 
the widest possible audience usefully to get the job done quick. The second 
placed sense has a range of possibility narrower than iterable as has been 
said, all sequences are iterables but not all iterables sequences.

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-25 Thread Van Ly

Van Ly added the comment:

The first mention of iterator should link to 'glossary.html#term-iterator'.

There is a builtin iter() function. This may cause confusion in earlier 
suggested inline sample code.

-- Use the following inline sample code 
-- in place of 'iter = enumerate(led)'to avoid confusion with iter() builtin:

led = ['red', 'green', 'blue']
iterator = enumerate(led)
try:
while True:
print iterator.next()
except StopIteration:
print 'End of iterator has been reached.'

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-25 Thread R. David Murray

R. David Murray added the comment:

I think you misunderstand the purpose of the documentation you are suggesting 
modifying.  It is a *reference guide*, and as such it needs to be technically 
precise and *must* correctly use the jargon of the language.  Especially 
since it also functions as the reference guide for people who implement new 
versions of Python, and need to know what behavior of things like 'enumerate' 
they need to reproduce.

That said, we also prefer the reference docs to be clear and understandable to 
someone who is a relative beginner, as long as we don't lose precision in doing 
so.  Thus the glossary and the glossary links, so yes it would be a good idea 
to add those.

I did indeed misspell iterable.

Your sentence is still incorrect...items returned by an iterator do not 
necessarily have an index (that is, you can't say myiterator[3] in the general 
case).

So, if I understand correctly, your difficulty was the confusion between the 
argument name *sequence* and the technical term ``sequence`` (referring to a 
Python object type).  I agree that that makes things confusing.  It would be 
better if the argument were named *iterable*, but we can't really change it at 
this point for backward compatibility reasons.

Maybe if we rearrange things a bit we can make it clearer.  How about this:

Return an enumerate object which when iterated[link to glossary] yields a 
two-tuple for each element in *sequence*, each tuple consisting of the sequence 
number of the element (beginning with *start*, which defaults to 0) paired with 
the element itself.  *sequence* must be a sequence, an iterator, or some other 
object which supports iteration.

That moves the distracting precise definition of *sequence* to the end, after 
you've already grasped what the function does.  You will note that I've also 
dropped the reference to next; that is implicit in the mention of when 
iterated, since it is an integral part of the iteration protocol. IMO it is a 
distraction to mention next in this context.  It confuses the beginner and 
isn't needed by the expert.

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-25 Thread Georg Brandl

Changes by Georg Brandl ge...@python.org:


--
nosy:  -georg.brandl

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-25 Thread Ethan Furman

Ethan Furman added the comment:

+1 for rdm's change.

--

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-24 Thread Van Ly

New submission from Van Ly:

The existing documentation is confusing. 

— improve wording as follows

enumerate(sequence, start=0)

Returns pairings of index into sequence[link to glossary.html#term-sequence] 
with the object at that index in the sequence.

— wording as found in v.2.7.5

enumerate(sequence, start=0)

Return an enumerate object. sequence must be a sequence, an iterator, or some 
other object which supports iteration. The next() method of the iterator 
returned by enumerate() returns a tuple containing a count (from start which 
defaults to 0) and the values obtained from iterating over sequence:

--
assignee: docs@python
components: Documentation
messages: 229979
nosy: docs@python, vy0123
priority: normal
severity: normal
status: open
title: improve documentation for enumerate() (built-in function)
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.5

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-24 Thread Ezio Melotti

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


--
nosy: +ezio.melotti
versions: +Python 3.4, Python 3.6 -Python 3.3

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



[issue22725] improve documentation for enumerate() (built-in function)

2014-10-24 Thread R. David Murray

R. David Murray added the comment:

The existing documentation is technically correct, while your replacement 
leaves some things out, such as the fact that enumerate accepts an iteratable 
and returns an iterator that is specifically a special 'enumerate object'. (A 
sequence is an iteratable, but not all iterables sequences, and enumerate 
specifically does *not* return a list of pairs, and it is important to know 
that).

Can you explain what it is you find confusing about the existing documentation? 
 The examples should go a long way toward clarifying the text for those not 
familiar enough with the precisely correct terms it uses.

--
nosy: +r.david.murray

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