[Python-Dev] Typo in itertools.dropwhile()

2007-07-12 Thread Matthieu Brucher

Hi,

There seems to be a typo in the doc of itertools.dropwhile() :

Make an iterator that drops elements from the iterable as long as the
predicate is true; afterwards, returns every element. Note, the iterator
does not produce *any* output until the predicate is true, so it may have a
lengthy start-up time.

It says something and then the opposite, so which one is true ?

Matthieu
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Typo in itertools.dropwhile()

2007-07-12 Thread Raymond Hettinger

[Matthieu on itertools.dropwhile() docs]
> Make an iterator that drops elements from the iterable as long as the 
> predicate is true; afterwards, returns every element. Note, 
> the iterator does not produce any output until the predicate is true, so it 
> may have a lengthy start-up time.
>
> It says something and then the opposite, so which one is true ?


It is correct as written.  Given a sequence where predicate is true 1000 times 
and then alternately false and true, it returns the 
part that is alternately false and true.  So, it did DROP (omit, not return, 
skip-over, etc) the first 1000 true items and it did 
return EVERY element from the first false to the end.  It did not produce any 
output for the first 1000 inputs so it took a while to 
get to the first output (the first false).  Hope that clears it up for you.


Raymond
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Typo in itertools.dropwhile()

2007-07-12 Thread Matthieu Brucher

2007/7/13, Raymond Hettinger <[EMAIL PROTECTED]>:



[Matthieu on itertools.dropwhile() docs]
> Make an iterator that drops elements from the iterable as long as the
predicate is true; afterwards, returns every element. Note,
> the iterator does not produce any output until the predicate is true, so
it may have a lengthy start-up time.
>
> It says something and then the opposite, so which one is true ?

It is correct as written.  Given a sequence where predicate is true 1000
times and then alternately false and true, it returns the
part that is alternately false and true.  So, it did DROP (omit, not
return, skip-over, etc) the first 1000 true items and it did
return EVERY element from the first false to the end.  It did not produce
any output for the first 1000 inputs so it took a while to
get to the first output (the first false).  Hope that clears it up for
you.



Hi,

Thanks for the answer.
I agree with you, but this explains the first sentence. The second says that
nothing is output until the predicate is true. It should say" while the
predicate is true" or "until the predicate is false". But I could be
misunderstand 'until' as well (English is not my mother tongue, but
still...)


Matthieu
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Typo in itertools.dropwhile()

2007-07-12 Thread Stephen J. Turnbull
Raymond Hettinger writes:

 > [Matthieu on itertools.dropwhile() docs]

 > > Note, the iterator does not produce any output until the
 > > predicate is true

 > it did return EVERY element from the first false

Shouldn't the "until" in the doc be "while"?  Alternatively, "true"
could be changed to "false".

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Typo in itertools.dropwhile()

2007-07-12 Thread Terry Reedy

"Stephen J. Turnbull" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| Raymond Hettinger writes:
|
| > [Matthieu on itertools.dropwhile() docs]
|
| > > Note, the iterator does not produce any output until the
| > > predicate is true
|
| > it did return EVERY element from the first false
|
| Shouldn't the "until" in the doc be "while"?  Alternatively, "true"
| could be changed to "false".

As I understand the first sentence, yes. 



___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Typo in itertools.dropwhile()

2007-07-13 Thread Matthieu Brucher

Thank you very much !

Matthieu

2007/7/13, Raymond Hettinger <[EMAIL PROTECTED]>:


[Stephen J. Turnbull]
> Shouldn't the "until" in the doc be "while"?  Alternatively, "true"
> could be changed to "false".

Yes.  I'll make the change.


Raymond

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Typo in itertools.dropwhile()

2007-07-13 Thread Chris Monson
Actually, I think it *is* a typo:  the last part should read that no
output is produced until the predicate becomes *false*.

- C


On 7/13/07, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
>
> [Matthieu on itertools.dropwhile() docs]
> > Make an iterator that drops elements from the iterable as long as the
> predicate is true; afterwards, returns every element. Note,
> > the iterator does not produce any output until the predicate is true, so
> it may have a lengthy start-up time.
> >
> > It says something and then the opposite, so which one is true ?
>
>
> It is correct as written.  Given a sequence where predicate is true 1000
> times and then alternately false and true, it returns the
> part that is alternately false and true.  So, it did DROP (omit, not return,
> skip-over, etc) the first 1000 true items and it did
> return EVERY element from the first false to the end.  It did not produce
> any output for the first 1000 inputs so it took a while to
> get to the first output (the first false).  Hope that clears it up for you.
>
>
> Raymond
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/shiblon%40gmail.com
>
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Typo in itertools.dropwhile()

2007-07-13 Thread Raymond Hettinger
[Stephen J. Turnbull]
> Shouldn't the "until" in the doc be "while"?  Alternatively, "true"
> could be changed to "false".

Yes.  I'll make the change.


Raymond
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com